.ceil()
Anonymous contributor
Anonymous contributor1 total contribution
Anonymous contributor
Published Dec 12, 2022
Contribute to Docs
The Math.ceil()
method returns the double
value that is a mathematical integer and is greater than or equal to the original value.
Syntax
Math.ceil(num)
- The result is the same as the argument if the argument value is already equal to a mathematical integer.
- The result is identical to the argument if the argument is
NaN
, +/- infinity, or +/- zero. - The parameter
num
is of typedouble
. - The result is of type
double
Example 1
The following example demonstrates using .ceil()
:
// Example.javapublic class Example {public static void main(String args[]) {Double value1 = 8.3;Double value2 = 8.9;System.out.println(Math.ceil(value1));System.out.println(Math.ceil(value2));}}
This results in the following output:
9.09.0
Example 2
The following example demonstrates using .ceil()
with negative numbers:
// Example.javapublic class Example {public static void main(String args[]) {Double value1 = -0.5;Double value2 = -1.3;System.out.println(Math.ceil(value1));System.out.println(Math.ceil(value2));}}
This results in the following output:
-0.0-1.0
All contributors
- Anonymous contributorAnonymous contributor1 total contribution
- Anonymous contributor
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.