Computer >> Computer tutorials >  >> Programming >> Python

How do I find the largest integer less than x in Python?


Python's floor() function returns nearest integer less than the given number.

>>> import math
>>> x=6.67
>>> math.floor(x)
6
>>> x=1.13
>>> math.floor(x)
1
>>> x=-5.78
>>> math.floor(x)
-6

Note that -6 is less than -5.78