Easy Tutorial
❮ Java Hashmap Isempty Java Object Classes ❯

Java ceil() Method

Java Number Class


The ceil() method rounds a number up to the nearest integer, returning a value greater than or equal to the given parameter, with a double precision floating-point type.

Syntax

The method has the following syntax formats:

double ceil(double d)

double ceil(float f)

Parameters

Return Value

Returns a double type, the returned value is greater than or equal to the given parameter.

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)); 
    }
}

Compiling the above program will produce the following output:

101.0
-90.0
100.0
-90.0

Java Number Class

❮ Java Hashmap Isempty Java Object Classes ❯