Tag Archives: math module

How to convert floating point numbers to integers in Python

Let’s consider you want to convert a floating point number into an integer. There are two ways of doing that.

Method 1 – Truncating

You can truncate the floating point number to just the portion before the decimal point. You can do that with the int() function which truncates the number towards zero.

>>> fpn = 57.83
>>> int(fpn)

Continue reading