Home » Java Math.ceil() method with Examples

Java Math.ceil() method with Examples

by Online Tutorials Library

Java Math.ceil() method

The java.lang.Math.ceil () is used to find the smallest integer value that is greater than or equal to the argument or mathematical integer.

Syntax

Parameter

Return

  • If the argument is positive or negative double value, this method will return the ceil value.
  • If the argument is NaN, this method will return same argument.
  • If the argument is Infinity, this method will return Infinity with the same sign as the argument.
  • If the argument is positive or negative Zero, this method will return Zero with same sign as the argument.
  • If the argument is less than Zero but greater than -1.0, this method will return Negative Zero as output.

Example 1

Test it Now

Output:

84.0  

Example 2

Test it Now

Output:

-94.0  

Example 3

Test it Now

Output:

-Infinity  

Example 4

Test it Now

Output:

0.0  

Example 5

Test it Now

Output:

-0.0  

Next TopicJava Math

You may also like