Python\'s math module contain handy functions like floor
& ceil
. These functions take a floating point number and return the nearest integer be
math.floor
will always return an integer number and thus int(math.floor(some_float))
will never introduce rounding errors.
The rounding error might already be introduced in math.floor(some_large_float)
, though, or even when storing a large number in a float in the first place. (Large numbers may lose precision when stored in floats.)