English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Java Math Mathematical Methods
The Java Math ceil() method rounds the specified double value up and returns it.
The rounded value should be equal to a mathematical integer. That is, the value3.4Should be rounded to4.0, equal to an integer4.
The syntax of the ceil() method is:
Math.ceil(double value)
Note:ceil() is a static method. Therefore, we can access this method using the class name Math.
value - The number to be rounded up
Returns the rounded value equal to a mathematical integer
Note: The returned value should be the smallest value that is greater than or equal to the specified parameter.
class Main { public static void main(String[] args) { //Math.ceil() Method. //is greater than the decimal point5The value double a = 1.878; System.out.println(Math.ceil(a)); // 2.0 //The value after the decimal point is equal to5 double b = 1.5; System.out.println(Math.ceil(b)); // 2.0 //is less than the decimal point5The value double c = 1.34; System.out.println(Math.ceil(c)); // 2.0 } }