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