What is Math.floor() in JAVA?
The floor() function returns the largest double value that is less than or equal to a specific number.
Figure 1, below, shows the mathematical representation of the floor() function.
Syntax
double floor(number num)
Parameter
This function requires a number as a parameter.
The number can be
int,float,double, orlong.
Return Value
floor() returns the largest double value that is less than or equal to a specific number.
Code
class JAVA {public static void main( String args[] ) {//integerSystem.out.println("Math.floor(2):");System.out.println(Math.floor(2));//positive double valueSystem.out.println("Math.floor(2.56):");System.out.println(Math.floor(2.56));//negative double valueSystem.out.println("Math.floor(-2.36):");System.out.println(Math.floor(-2.36));}}