Java Tutorial

Java Control Statements

Object Oriented Programming

Java Built-in Classes

Java File Handling

Java Error & Exceptions

Java Multithreading

Java Synchronization

Java Networking

Java Collections

Java Interfaces

Java Data Structures

Java Collections Algorithms

Advanced Java

Java Miscellaneous

Java APIs & Frameworks

Java Class References

Java Useful Resources

Java - ceil() Method



Description

The method ceil gives the smallest integer that is greater than or equal to the argument.

Syntax

This method has the following variants −

double ceil(double d)
double ceil(float f)

Parameters

Here is the detail of parameters −

  • A double or float primitive data type.

Return Value

  • This method returns the smallest integer that is greater than or equal to the argument. Returned as a double.

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

This will produce the following result −

Output

-100.0
-90.0
-101.0
-90.0
java_numbers.htm
Advertisements