math.ceil
Defined in module
"math"from "math" import ceilRounds x upward to the nearest integer
Parameters
x | number | the number to round |
Return value
The smallest integer value that is not less than x.
Notes
The result is always a float, even when x is already an integer. For a negative x, "upward" moves toward zero, not away from it: ceil(-3.2) is -3.
Example
from "math" import ceil
println("ceil(3.2) =", ceil(3.2))
println("ceil(-3.2) =", ceil(-3.2))
// upward means toward positive infinity, so a negative x moves toward zero
println("type(ceil(3.2)) =", type(ceil(3.2)))Output:
ceil(3.2) = 4
ceil(-3.2) = -3
type(ceil(3.2)) = floatSee also
floor | Rounds x downward to the nearest integer |
round | Rounds x to the nearest integer |
abs | Returns the absolute value of x |
| math | module index |