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.
Syntax :
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.
Examples :
Input: num = 9.6 Output: 9.0 Input: num = -7.8 Output: -8.0
Below programs illustrate the java.lang.StrictMath.floor() method:
Program 1:
// Java praogram to illustrate the //java.lang.StrictMath.floor() import java.lang.*; public class Geeks { public static void main(String[] args) { double num1 = 7.8, num2 = 1.4 ; double fValue = StrictMath.floor(num1); System.out.println("The floor value of "+ num1+" = " + fValue); fValue = StrictMath.floor(num2); System.out.println("The floor value of "+ num2+" = " + fValue); } } |
The floor value of 7.8 = 7.0 The floor value of 1.4 = 1.0
Program2:
// Java praogram to illustrate the //java.lang.StrictMath.floor() import java.lang.*; public class Geeks { public static void main(String[] args) { double num1 = -7.8, num2 = -1.4 ,num3 = 0.1 ; double fValue = StrictMath.floor(num1); System.out.println("The floor value of "+ num1+" = " + fValue); fValue = StrictMath.floor(num2); System.out.println("The floor value of "+ num2+" = " + fValue); fValue = StrictMath.floor(num3); System.out.println("The floor value of "+ num3+" = " + fValue); } } |
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 and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- Java.lang.StrictMath class in Java | Set 1
- Java.lang.StrictMath class in Java | Set 2
- StrictMath log1p() Method in Java
- StrictMath IEEEremainder() Method in Java
- StrictMath nextAfter() Method in Java
- StrictMath tan() Method in Java
- StrictMath atan2() Method in Java
- StrictMath hypot() Method in Java
- StrictMath acos() Method in Java
- StrictMath asin() Method in Java With Examples
- StrictMath atan() Method in Java
- StrictMath cbrt() Method in Java
- StrictMath ceil() Method in Java with Examples
- StrictMath cos() Method in Java with Examples
- StrictMath exp() Method in Java
- StrictMath cosh() Method in Java
- StrictMath expm1() Method in Java With Examples
- StrictMath getExponent() Method In Java
- StrictMath log() Method In Java
- StrictMath log10() Method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

