The ceil() method of Math class returns the smallest double value which is closest to negative infinity and is greater than or equal to the argument.

Syntax:

public static double ceil(double a)

Parameters:

The parameter ‘a’ represents a value.

Return Value:

The ceil() method returns the smallest floating-point value greater than or equal to argument and is equal to a mathematical integer.

  • It returns same value as the argument, if the argument value is equal to a mathematical integer.
  • It returns the same value as the argument, if we pass a NaN or infinity or positive zero or negative zero argument.
  • It will return negative zero, if the argument value is less than zero but greater than -1.0.

Example 1:

 Output:

Example 2:

 Output:

Example 3:

 Output:

Example 4:

 Output:

Pin It on Pinterest

Share This