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

PythonServer Side ProgrammingProgramming

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

raja
Updated on 02-Mar-2020 10:05:01

Advertisements