xxxxxxxxxx
The ceiling of a floating point number is the smallest integer that is >= to the number.
xxxxxxxxxx
Math.ceil(125.9)=126.0
Math.ceil(0.4873)=1.0
Math.ceil(-0.65)=-0.0
xxxxxxxxxx
package com.tutorialspoint;
import java.lang.*;
public class MathDemo {
public static void main(String[] args) {
// get two double numbers
double x = 125.9;
double y = 0.4873;
// call ceal for these these numbers
System.out.println("Math.ceil(" + -4.8 + ")=" + Math.ceil(-4.8));
System.out.println("Math.ceil(" + y + ")=" + Math.ceil(y));
System.out.println("Math.ceil(-0.65)=" + Math.ceil(-0.65));
}
}
xxxxxxxxxx
import java.lang.Math;
public class Main {
public static void main(String[] args) {
double number = 3.14;
double result = Math.ceil(number);
System.out.println(result);
}
}