The technique ceil provides the negligible integer that is better than or equivalent to the argument. ceil() returns the twice value that is better than or equivalent to the argument and is equivalent to the nearest mathematical integer. Note: If the argument is a figure, then the result is Integer. If the argument is NaN or an infinity or constructive zero or negative zero, then the product is the same as the argument.
This method has the following variants:
double ceil(double d) double ceil(float f)
Here is the detail of parameters −
Example
public class Test { public static void main(String args[]) { double d = -100.675; float f = -90; System.out.println(Math.ceil(d)); System.out.println(Math.ceil(f)); System.out.println(Math.floor(d)); System.out.println(Math.floor(f)); } }
This will produce the following result −
Output
-100.0 -90.0 -101.0 -90.0
Here at Intellinuts, we have created a complete Java tutorial for Beginners to get started in Java.