math.floor
Defined in module
"math"from "math" import floorRounds x downward to the nearest integer
Parameters
x | number | the number to round |
Return value
The largest integer value that is not greater than x.
Notes
The result is always a float, even when x is already an integer: type(floor(3)) gives "float", not "integer". Convert with int(...) when an integer value is required.
Example
from "math" import floor
println("floor(3.7) =", floor(3.7))
println("floor(-3.7) =", floor(-3.7))
// the result is a float even though it already looks like a whole number
println("type(floor(3.7)) =", type(floor(3.7)))
println("type(floor(3)) =", type(floor(3)))Output:
floor(3.7) = 3
floor(-3.7) = -4
type(floor(3.7)) = float
type(floor(3)) = floatSee also
ceil | Rounds x upward to the nearest integer |
round | Rounds x to the nearest integer |
abs | Returns the absolute value of x |
| math | module index |