On this page
math.floor
Prev: math.factorial | Up: math | Next: math.fma
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.floor
Tags: #public #python3 #stdlib #math
Import
import math
from math import floor
Signature & Overview
math.floor(x, /)
Return the floor of x as an Integral.
Usage
import math
assert math.floor(2.9) == 2
assert math.floor(-2.1) == -3
Gotchas
- Rounds toward $-\infty$ (unlike
int()which truncates toward0):math.floor(-2.1)is-3, whereasint(-2.1)is-2.
REPL Inspect
from math import floor
help(floor)
Linked from
Related notes
- tuts/python3/stdlib_module/math/factorial Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/fma Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/math/acos Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/acosh Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asin Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asinh Linked here; shared tags: #math, #stdlib
- tuts/c/stdlib/math shared tags: #math, #stdlib
- tuts/c/stdlib/math/fabs shared tags: #math, #stdlib
- tuts/c/stdlib/math/floor shared tags: #math, #stdlib