java.lang.Math floor(double a)

Description :

This java tutorial shows how to use the floor(double) method of Math class under java.lang package. This method 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.

Method Syntax :

public static double floor(double a)

Parameter Input :

DataType Parameter Description
double a a value

Method Returns :

The floor(double a) method simply returns returns the largest double value that is less than or equal to the argument and is equal to an integer. Special cases:

  • 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.

Compatibility Version :

Requires Java 1.0 and up

Exception :

N/A

Java Code Example :

This java example source code demonstrates the use of floor(double a) method of Math class. Basically we just get the floor value of a double variable coming from the user input.

Sample Output :

Running the abs(double a) method example source code of Math class will give you the following output

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :