There are two types of numbers in Python.
- integers
- floating-point
The integers are either positive numbers, negative numbers, or 0. Commonly referenced as int.
The floating-point numbers can contain decimals, whereas integers cannot. To convert a number stored in a string or integer convert into a floating-point number, use the float() function.
The math.floor() function in Python rounds a number down to the nearest integer and returns the result. Let’s see how to work with floating-values with floor() function.
Python floor float
To use a floor float in Python, use the int() function as long as your numbers are positive. The int() function can round down to the next integer. Then, the int() method on the float can be cast to that value to the lower int.
data = 3.1415161
rnd = int(data)
print(rnd)
Output
3
In this example, the int() function round down the 3.1415161 value to 3.
If you want the floating-point value output like 3.0 floating value, you can use the floor division(//) operator.
import math
data = 3.1415161
rnd = data // 1
print(rnd)
Output
3.0
You can see that we got the floating-point output.
Python floor float for negative numbers
If you use the floor division operator to the negative numbers, it gives the round-up value.
import math
data = -3.1415161
rnd = data // 1
print(rnd)
Output
-4.0
That’s it for this tutorial.

Krunal Lathiya is a Software Engineer with over eight years of experience. He has developed a strong foundation in computer science principles and a passion for problem-solving. In addition, Krunal has excellent knowledge of Data Science and Machine Learning, and he is an expert in R Language. Krunal has experience with various programming languages and technologies, including PHP, Python, and JavaScript. He is comfortable working in front-end and back-end development.