Description: Java's java.io package provides classes for input and output operations. The Math class in java is used to perform mathematical operations. The ceil() method of the Math class returns the smallest integer value that is greater than or equal to a given double or float value. This method is useful when we want to round-up a decimal number to its nearest integer.
Code Example:
double num = 5.2; int roundedNum = (int) Math.ceil(num); // returns 6 System.out.println(roundedNum);
In this example, we declare a variable num with a value of 5.2. We then use the Math.ceil() method to round the number up to its nearest integer value, which returns 6. We then print the rounded value to the console.
Package Library: The ceil() method is part of the Math class in the java.lang package, which is automatically imported into every Java program.
Java Math.ceil - 30 examples found. These are the top rated real world Java examples of java.io.Math.ceil extracted from open source projects. You can rate examples to help us improve the quality of examples.