How to Find Ceiling Value of a Number in Java


The example aims to find a ceiling value of a number by ceil method in Java.

Source Code

package com.beginner.examples;

public class CeilExample {

    public static void main(String[] args){
    	//return the smallest interger which is not less than the value.
    	System.out.println(Math.ceil(6));
        System.out.println(Math.ceil(6.3));       
        System.out.println(Math.ceil(-12.6));
        //returns 0
        System.out.println(Math.ceil(0));
    }
}

Output:

6.0
7.0
-12.0
0.0
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments