int(x)

Conversion to integer will truncate (towards 0.0), like math.trunc.
For non-negative numbers, this is downward.

If your number can be negative, this will round the magnitude downward, unlike math.floor which rounds towards -Infinity, making a lower value. (Less positive or more negative).

Python integers are arbitrary precision, so even very large floats can be represented as integers. (Unlike in other languages where this idiom could fail for floats larger than the largest value for an integer type.)

Answer from Ghostwriter on Stack Overflow
🌐
Real Python
realpython.com › python-rounding
How to Round Numbers in Python – Real Python
December 7, 2024 - For example, the number 2.5 rounded to the nearest whole number is 3. The number 1.64 rounded to one decimal place is 1.6. Now open up an interpreter session and round 2.5 to the nearest whole number using Python’s built-in round() function:
🌐
FavTutor
favtutor.com › blogs › round-down-python
Round Down Numbers in Python (With Examples and Code)
September 3, 2022 - Rounding is the practice of simplifying a number without modifying much of its value. For instance, 9.8 rounded to 10, with only a 0.2 difference. Likewise, 10.2 rounded to 10, with the same difference.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-round-numbers-up-or-down-in-python
Python Round to Int – How to Round Up or Round Down to the Nearest Whole Number
May 24, 2022 - Let's see an example. import math x = 5.57468465 print(math.floor(x)) # 5 · As expected, we passed in the number to be rounded down to the math.floor() method: math.floor(x). The x variable has the number 5.57468465 stored in it.
🌐
Replit
replit.com › home › discover › how to round down in python
How to round down in Python
When you divide a number by 1 using this operator, Python performs floor division, which effectively rounds the number down to the nearest whole number.
🌐
Altcademy
altcademy.com › blog › how-to-round-down-in-python
How to round down in Python
June 13, 2023 - This is effectively rounding down the number. To use the math.floor() function, you first need to import the math library. Here's an example of how you can round down a number using math.floor():
🌐
Python Pool
pythonpool.com › home › blog › best ways to round down numbers in python
Best Ways to Round Down Numbers in Python - Python Pool
January 1, 2024 - We have not passed any value to ... in this example. As a result, it takes the default value, i.e., 0. We can see that the integer number remains as it is, 12.7 is rounded up to 13, and 12.4 is rounded down to 12.
Find elsewhere
🌐
Note.nkmk.me
note.nkmk.me › home › python
Round Up/Down Decimals in Python: math.floor, math.ceil | note.nkmk.me
January 15, 2024 - Convert a string to a number (int, float) in Python · print(int('10')) # 10 # print(int('10.123')) # ValueError: invalid literal for int() with base 10: '10.123' print(int('FF', 16)) # 255 ... Considering negative values, there are four ways to round up and down. ... print(math.floor(10.123)) # 10 print(math.floor(-10.123)) # -11 print(math.ceil(10.123)) # 11 print(math.ceil(-10.123)) # -10 print(int(10.123)) # 10 print(int(-10.123)) # -10 ... For example, you can define a custom function that rounds toward infinity as follows.
🌐
W3Schools
w3schools.com › python › ref_func_round.asp
Python round() Function
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... The round() function returns a floating point number that is a rounded version of the specified number, with the specified number of decimals.
🌐
W3Schools
w3schools.com › python › ref_math_floor.asp
Python math.floor() Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... # Import math library import math # Round numbers down to the nearest integer print(math.floor(0.6)) print(math.floor(1.4)) print(math.floor(5.3)) print(math.floor(-5.3)) print(math.floor(22.6)) print(math.floor(10.0)) Try it Yourself »
🌐
LabEx
labex.io › tutorials › python-how-to-round-down-a-float-to-an-integer-in-python-415546
How to round down a float to an integer in Python | LabEx
This ensures that you access the correct element in the data structure. import numpy as np ## Example of rounding down a float to an integer index data = [10.2, 15.7, 8.4, 12.9] index = int(np.floor(3.7)) print(data[index]) ## Output: 12.9
🌐
TradingCode
tradingcode.net › python › math › round-decimals
How to round decimal places up and down in Python? • TradingCode
Original values: [22.459, 5.963, 2.335, -1.569, -0.019, -22.3] Rounded up and down to 2 decimals: [22.46, 5.96, 2.33, -1.57, -0.02, -22.3] Rounded up to 2 decimals: [22.46, 5.97, 2.34, -1.56, -0.01, -22.3] Rounded down to 2 decimals: [22.45, ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › floor-ceil-function-python
floor() and ceil() function Python - GeeksforGeeks
Python’s math module provides many useful mathematical functions, including floor() and ceil(), which are commonly used for rounding numbers. floor(): Rounds a number down to the nearest integer. Example: floor() of 3.3 will be 3.
Published   January 10, 2018
🌐
Vultr Docs
docs.vultr.com › python › third-party › numpy › floor
Python Numpy floor() - Round Down Values | Vultr Docs
November 14, 2024 - The code outputs 3.0. numpy.floor() rounds down 3.7 to the nearest whole number, which is 3.
🌐
Inspector
inspector.dev › home › round up numbers to integer in python – fast tips
Round Up Numbers to Integer in Python - Inspector.dev
June 17, 2025 - In the second example, math.floor() is used to round down num3 (5.2) to the nearest integer, resulting in 5.
🌐
Mimo
mimo.org › glossary › python › round-function
Python round(): Rounding Numbers in Python
Using a negative value for the ndigits parameter, the round() function can round a floating-point number or integer to a multiple of 10. In the following example, we round 12345 to the nearest hundred (12300), simplifying the value. ... Python’s round() function works well in many cases.
🌐
GeeksforGeeks
geeksforgeeks.org › python › round-function-python
round() function in Python - GeeksforGeeks
In the given example, round(-3.2) is converted into -3 is the nearest integer to -3.2. Similarly, round(-4.7) returns -5 since -5 is closer to -4.7 than -4. Similarly round(-2.5) returns -2 because it rounds down when the decimal part is exactly ...
Published   August 7, 2024
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-round-numbers-in-python
How to Round Numbers in Python? - GeeksforGeeks
July 15, 2025 - For example, Input is 3.5 then Output should be 4. Python’s built-in round() function rounds a number to a given precision.