According to the same Javadoc:

If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument. Can't do that with an int.

The largest double value is also larger than the largest int, so it would have to be a long.

Answer from krosenvold on Stack Overflow
🌐
W3Schools
w3schools.com › java › ref_math_floor.asp
Java Math floor() Method
Note: For positive numbers the floor() method just removes the decimal part, but for negative numbers the integer part of the number will be changed if the number has a decimal part.
People also ask

What is the Math floor in Java?
Math floor in Java is a mathematical function in the programming language that rounds down a given decimal number to the nearest integer. To be precise, it returns the largest integer less than or equal to the given number while discarding the decimal part. What is the Math floor (-4.7) in Java?
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › math floor in java
Math floor() Function in Java with Examples | upGrad
What is the Math floor (-4.7) in Java?
As we know, the Math.floor() function rounds the given number to its nearest integer, which will be less than or equal to the number. Therefore, in this case, the result of the Math.floor(-4.7) is -5 . As we know, the Math.floor() function rounds the given number to its nearest integer, which will be less than or equal to the number. Therefore, in this case, the result of the Math.floor(-4.7) is -5 . How to apply floor in Java?
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › math floor in java
Math floor() Function in Java with Examples | upGrad
What is Math.floor JavaScript?
Math.floor is a JavaScript function that rounds a number down to the nearest integer, returning the largest integer less than or equal to the given number. Math.floor is a JavaScript function that rounds a number down to the nearest integer, returning the largest integer less than or equal to the given number.
🌐
upgrad.com
upgrad.com › home › tutorials › software & tech › math floor in java
Math floor() Function in Java with Examples | upGrad
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-floor-method-examples
Java floor() method with Examples - GeeksforGeeks
April 7, 2018 - The Math.floor() method in Java returns the largest integer value that is less than or equal to a given number. The result is returned as a double and represents the mathematical floor of the argument.
🌐
Programiz
programiz.com › java-programming › library › math › floor
Java Math floor()
That is, the value 3.8 will be rounded to 3.0 which is equal to integer 3. class Main { public static void main(String[] args) { double a = 3.8; System.out.println(Math.floor(a)); } } // Output: 3.0
🌐
CodeGym
codegym.cc › java blog › java numbers › java floor() method
Java floor() method
December 5, 2024 - Math.floor() method in Java returns a “double” value equal to the greatest integer less than or equal to the argument. If the given number is already an integer it returns the integer.
🌐
Vultr Docs
docs.vultr.com › java › standard-library › java › lang › Math › floor
Java Math floor() - Round Down Value | Vultr Docs
December 3, 2024 - The Math.floor() method in Java is a crucial tool when it comes to rounding down floating-point numbers to the nearest integer that is less than or equal to the specified number.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › math floor in java
Math floor() Function in Java with Examples | upGrad
1 month ago - Math floor in Java is a mathematical function in the programming language that rounds down a given decimal number to the nearest integer. To be precise, it returns the largest integer less than or equal to the given number while discarding the ...
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java math floor function
Java Math Floor Function
September 1, 2008 - The Java Math floor(double a) returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.
🌐
Scaler
scaler.com › home › topics › math.floor() in java
Math floor() Java | Math.floor() Function in Java - Scaler Topics
May 5, 2024 - The return value of the Math floor() function in Java is a double value equal to the integer value immediately smaller than the floating number passed to it.
🌐
Codecademy
codecademy.com › docs › java › math methods › .floor()
Java | Math Methods | .floor() | Codecademy
November 10, 2022 - The Math.floor() method returns the largest integer value that is less than or equal to the argument. ... Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
🌐
Javatpoint
javatpoint.com › java-math-floor-method
Java Math.floor() method with Examples - Javatpoint
The java.lang.Math.floor() is used to find the largest integer value which is less than or equal to the argument and is equal to the mathematical integer of a double value · Java method The Java.lang.math.min() is an inbuilt method in Java which is used to return Minimum or Lowest value from ...
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Math.html
Math (Java Platform SE 8 )
October 20, 2025 - If the argument value is already equal to a mathematical integer, then the result is the same as the argument. If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument. If the argument value is less than zero but greater than -1.0, then the result is negative zero. Note that the value of Math.ceil(x) is exactly the value of -Math.floor...
🌐
Tutorialspoint
tutorialspoint.com › home › java › java number floor method
Java Number Floor Method
September 1, 2008 - This method returns the largest integer that is less than or equal to the argument. Returned as a double. public class Test { public static void main(String args[]) { double d = -100.675; float f = -90; System.out.println(Math.floor(d)); ...
🌐
Tabnine
tabnine.com › home page › code › java › java.lang.math
java.lang.Math.floor java code examples | Tabnine
value = Number.MAX_SAFE_INTEGER/10 // 900719925474099.1 Math.floor(value) // 900719925474099 Math.ceil(value) // 900719925474100 Math.round(value) // 900719925474099 Math.trunc(value) // 900719925474099 parseInt(value) // 900719925474099 value | 0 // 858993459 ~~value // 858993459 value >> 0 // 858993459 value >>> 0 // 858993459 value - value % 1 // 900719925474099
🌐
CodeAhoy
codeahoy.com › java › Math-Floor-method-JI_14
Java Math.floor() Method with Examples | CodeAhoy
October 12, 2019 - If the argument value is already equal to a mathematical integer, then the result is the same as the argument. If the argument is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument. If you need more detailed information, please see Javadocs.
🌐
TutorialKart
tutorialkart.com › java › java-math › java-math-floor
Java Math.floor() - Examples
November 23, 2020 - Since the definition of floor() function has double datatype as argument, you can pass int, float or long as arguments; because these datatypes could implicitly promote to double.
🌐
Tutorial Gateway
tutorialgateway.org › java-floor-function
Java floor Function
March 26, 2025 - The following function will accept positive or negative double values as an argument. It returns the closest double value, which is less than or equal to the specified expression or Value and equal to a mathematical integer.
🌐
Guru99
guru99.com › home › java tutorials › java math – ceil() floor() methods
Java Math – ceil() Floor() Methods
September 20, 2024 - Ceiling of '84.6' = 85.0 Floor of '84.6' = 84.0 Ceiling of '0.45' = 1.0 Floor of '0.45' = 0.0 · The Java Math.min() method returns the smallest of the two arguments. public class Guru99 { public static void main(String args[]) { int i1 = 27; int i2 = -45; double d1 = 84.6; double d2 = 0.45; System.out.println("Minimum out of '" + i1 + "' and '" + i2 + "' = " + Math.min(i1, i2)); System.out.println("Maximum out of '" + i1 + "' and '" + i2 + "' = " + Math.max(i1, i2)); System.out.println("Minimum out of '" + d1 + "' and '" + d2 + "' = " + Math.min(d1, d2)); System.out.println("Maximum out of '" + d1 + "' and '" + d2 + "' = " + Math.max(d1, d2)); } } Expected Output: Minimum out of '27' and '-45' = -45 Maximum out of '27' and '-45' = 27 Minimum out of '84.6' and '0.45' = 0.45 Maximum out of '84.6' and '0.45' = 84.6 ·
🌐
Dot Net Perls
dotnetperls.com › math-floor-java
Java - Math.floor Method, floorDiv and floorMod - Dot Net Perls
Floor returns an int but we can store this in a double if we want. Detail We use System.out.println to display the double results to the console. import java.lang.Math; public class Program { public static void main(String[] args) { // These are all reduced, even the negative number.
🌐
Narkive
comp.lang.java.help.narkive.com › gcS5laFk › math-floor
Math.Floor
Post by Hal Rosser Math.floor(...) ... for Math.round() says the method is equal to (long)Math.floor(a + 0.5d) Concept - the floor function will take the integer part of the number....