The java.lang.StrictMath.floor() is the inbuilt method which returns the largest double value, less than or equal to the given argument and is equal to the integer value.
- The result is the same as the argument when the given argument is equal to the integer.
- The result is the same as the argument when the given argument is NaN, infinity, positive zero or negative zero.
public static double floor(double num)
Parameters: This method accepts one parameter num which is of double type .
Return Value : The method returns the largest value which, closest to positive infinity, less than or equal to the argument and equal to an integer.
Input: num = 9.6 Output: 9.0 Input: num = -7.8 Output: -8.0
Below programs illustrate the java.lang.StrictMath.floor() method:
The floor value of 7.8 = 7.0 The floor value of 1.4 = 1.0
The floor value of -7.8 = -8.0 The floor value of -1.4 = -2.0 The floor value of 0.1 = 0.0
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.