# Get floor value of a number using Math.floor in Java

Java 8Object Oriented ProgrammingProgramming

To get the floor value of a number, we use the java.lang.Math.floor() method. The Math.floor() method returns the largest (closest to positive infinity) double value which is less than or equal to the parameter and has a value which is equal to a mathematical integer on the number line. If the parameter is NaN or an infinity or positive zero or negative zero, then the result is the same as the argument.

Declaration - The java.lang.Math.floor() method is declared as follows −

public static double floor(double a)

Let us see a program to get the floor value of a number in Java.

## Example

Live Demo

import java.lang.Math;
public class Example {
public static void main(String[] args) {
// declaring and initialising some double values
double a = -100.01d;
double b = 34.6;
double c = 600;
// printing their floor values
System.out.println("Floor value of " + a + " = " + Math.floor(a));
System.out.println("Floor value of " + b + " = " + Math.floor(b));
System.out.println("Floor value of " + c + " = " + Math.floor(c));
}
}

## Output

Floor value of -100.01 = -101.0
Floor value of 34.6 = 34.0
Floor value of 600.0 = 600.0