Float to integer

In programming, a floating point number is any number with a decimal (like 4.8). An integer is a whole number (like 4).

Sometimes, you’ll need to convert a floating point number to an integer. This process is called type conversion or type casting.

In Python, you use the int() function to convert a decimal number to a whole number.

Code example

# Convert a decimal to a whole number
number = 6.9
whole = int(number)  # Removes the decimal part (not rounded)
print(whole)  # Output: 6