java.lang.Math ceil(double a)

Description :

This java tutorial shows how to use the ceil(double a) method of Math class under java.lang package. This method returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.

Method Syntax :

public static double ceil(double a)

Parameter Input :

DataType Parameter Description
double a a value

Method Returns :

The ceil(double a) method simply returns the smallest (closest to negative infinity) floating-point value that is greater than or equal to the argument and is equal to a mathematical integer.. Consider the following 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.
  • If the argument value is less than zero but greater than -1.0, then the result is negative zero.

Compatibility Version :

Requires Java 1.0 and up

Exception :

N/A

Java Code Example :

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

Sample Output :

Running the ceil(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 :