The Numeric Types section documents this behaviour explicitly:

round(x[, n])
x rounded to n digits, rounding half to even. If n is omitted, it defaults to 0.

Note the rounding half to even. This is also called bankers rounding; instead of always rounding up or down (compounding rounding errors), by rounding to the nearest even number you average out rounding errors.

If you need more control over the rounding behaviour, use the decimal module, which lets you specify exactly what rounding strategy should be used.

For example, to round up from half:

>>> from decimal import localcontext, Decimal, ROUND_HALF_UP
>>> with localcontext() as ctx:
...     ctx.rounding = ROUND_HALF_UP
...     for i in range(1, 15, 2):
...         n = Decimal(i) / 2
...         print(n, '=>', n.to_integral_value())
...
0.5 => 1
1.5 => 2
2.5 => 3
3.5 => 4
4.5 => 5
5.5 => 6
6.5 => 7
Answer from Martijn Pieters on Stack Overflow
🌐
Real Python
realpython.com › python-rounding
How to Round Numbers in Python – Real Python
December 7, 2024 - If you first take the absolute value of n using Python’s built-in abs() function, then you can just use round_half_up() to round the number. Then all you need to do is give the rounded number the same sign as n.
🌐
Reddit
reddit.com › r/learnpython › using round_half_up to round numbers
r/learnpython on Reddit: Using round_half_up to round numbers
March 7, 2022 -

I don't want to round to the nearest even number, I just want to always round my halve up.

I just want to do something like:

import decimal print(round_half_up(2.5))

But I've figured out that's not right. How would I do that?

Edit:

If anyone is curious why. I'm graphing some data I rounded. The even numbers are clearly bigger than the odd numbers

🌐
Python.org
discuss.python.org › python help
Round half up Error - Python Help - Discussions on Python.org
January 18, 2023 - I need to round to the nearest whole number so 2.5 should be 3 and 2.4 should be 2. I am trying to use round_half_up to get around the round half even issue. The error I get: conversion from Series to Decimal is not su…
Top answer
1 of 4
17

Notice that when you call round you are getting a float value as a result, not a Decimal. round is coercing the value to a float and then rounding that according to the rules for rounding a float.

If you use the optional ndigits parameter when you call round() you will get back a Decimal result and in this case it will round the way you expected.

Python 3.4.1 (default, Sep 24 2015, 20:41:10) 
[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import decimal
>>> context = decimal.getcontext()
>>> context.rounding = decimal.ROUND_HALF_UP
>>> round(decimal.Decimal('2.5'), 0)
Decimal('3')

I haven't found where it is documented that round(someDecimal) returns an int but round(someDecimal, ndigits) returns a decimal, but that seems to be what happens in Python 3.3 and later. In Python 2.7 you always get a float back when you call round() but Python 3.3 improved the integration of Decimal with the Python builtins.

As noted in a comment, round() delegates to Decimal.__round__() and that indeed shows the same behaviour:

>>> Decimal('2.5').__round__()
2
>>> Decimal('2.5').__round__(0)
Decimal('3')

I note that the documentation for Fraction says:

__round__()
__round__(ndigits)
The first version returns the nearest int to self, rounding half to even.
The second version rounds self to the nearest multiple of Fraction(1, 10**ndigits)
(logically, if ndigits is negative), again rounding half toward even. 
This method can also be accessed through the round() function.

Thus the behaviour is consistent in that with no argument it changes the type of the result and rounds half to even, however it seems that Decimal fails to document the behaviour of its __round__ method.

Edit to note as Barry Hurley says in the comments, round() is documented as returning a int if called without the optional arguments and a "floating point value" if given the optional argument. https://docs.python.org/3/library/functions.html#round

2 of 4
4

Expanding on @Duncan's answer, the round builtin function changed between python 2 and python 3 to round to the nearest even number (which is the norm in statistics).

Python2 docs:

...if two multiples are equally close, rounding is done away from 0 (so, for example, round(0.5) is 1.0 and round(-0.5) is -1.0).

Python3 docs:

...if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2)

Since round converts to float if no argument is given for ndigits (credit to @Duncan's answer), round behaves the same way as it would for floats.

Examples (in python3):

>>> round(2.5)
2
>>> round(2.500000001)
3
>>> round(3.5)
4
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-round-numbers-in-python
How to Round Numbers in Python? - GeeksforGeeks
July 15, 2025 - Always rounds .5 upward. python · import math def round_half_up(num, dec=0): mult = 10 ** dec return math.floor(num * mult + 0.5) / mult print(round_half_up(1.28, 1)) print(round_half_up(-1.5)) print(round_half_up(-1.225, 2)) Output · 1.3 -1.0 -1.23 · Explanation: Adds 0.5 before flooring to simulate "round half up."
🌐
DataCamp
datacamp.com › tutorial › python-round-up
How to Round Up a Number in Python | DataCamp
July 22, 2024 - You can use the math.ceil() function from the math module to round up to the nearest int in Python. Rounding bias occurs when there are inaccurate values due to distortion of numbers when rounding.
🌐
Python
docs.python.org › 3 › library › decimal.html
decimal — Decimal fixed-point and floating-point arithmetic
This is a standard context defined by the General Decimal Arithmetic Specification. Precision is set to nine. Rounding is set to ROUND_HALF_UP. All flags are cleared.
Find elsewhere
🌐
Note.nkmk.me
note.nkmk.me › home › python
Round Numbers in Python: round(), Decimal.quantize() | note.nkmk.me
January 15, 2024 - decimal.Decimal.quantize() — Python 3.12.1 documentation · Specify a Decimal with the desired precision as the first argument. You can specify Decimal() with a string like '0.1' or '0.01'. To round the integer part, use scientific notation like '1E1'. More details will be discussed later. f = 123.456 print(Decimal(str(f)).quantize(Decimal('0'), ROUND_HALF_UP)) print(Decimal(str(f)).quantize(Decimal('0.1'), ROUND_HALF_UP)) print(Decimal(str(f)).quantize(Decimal('0.01'), ROUND_HALF_UP)) # 123 # 123.5 # 123.46
🌐
Hyperskill
hyperskill.org › university › python › rounding-and-round-in-python
Rounding and round() in Python
August 2, 2024 - Python provides several rounding methods for handling cases where the fractional part is exactly halfway between two integers. These rounding methods are implemented in the built-in round() function and the Decimal class. ROUND_HALF_UP: Rounds towards the nearest integer and if the fractional ...
🌐
Python
bugs.python.org › issue21179
Issue 21179: Rounding half to even - Python tracker
This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/65378
🌐
w3resource
w3resource.com › python-exercises › modules › python-module-decimal-exercise-5.php
Python: Configure the rounding to round to the nearest - with ties going towards 0, with ties going away from 0 - w3resource
Write a Python program that can be configured to round to the nearest - with ties going towards 0 and ties going away from 0. Use decimal.ROUND_HALF_DOWN, decimal.ROUND_HALF_UP
🌐
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 - If you want to round numbers with fractional parts that are exactly halfway between two integers away from zero, you can use the decimal module’s ROUND_HALF_UP constant.
🌐
The Renegade Coder
therenegadecoder.com › code › how-to-round-a-number-in-python
How to Round a Number in Python: Truncation, Arithmetic, and More – The Renegade Coder
May 28, 2024 - For instance, we could truncate ... I built my own “round-half-up” solution using the ternary operator: int(x + .5) if x >= 0 else int(x - .5)....
🌐
Software Testing Help
softwaretestinghelp.com › home › python › python round function: rounding numbers in python
Python Round Function: Rounding Numbers in Python
April 1, 2025 - Answer: The round() is a built-in ... then returns the closest multiple of 10-ndigits but breaks ties by applying the ROUNDING HALF TO EVEN strategy, which rounds to the ......
🌐
Real Python
realpython.com › lessons › rounding-half-up-down
Rounding Half Up and Half Down (Video) – Real Python
00:25 So if you’re thinking back ... 00:41 Here are two strategies that use a similar approach. Rounding half up adds 0.5 and takes the floor....
Published   June 18, 2024
🌐
GitHub
gist.github.com › serge-m › de45997d87fcc2e8a869a5f2a5cc4fb9
round half up in python · GitHub
round half up in python. GitHub Gist: instantly share code, notes, and snippets.
🌐
Python.org
discuss.python.org › python help
Trying to understand rounding - in python - - Python Help - Discussions on Python.org
June 17, 2023 - hello @all, I’m new here, pls. be tolerant if I harm habits I don’t know about, I’m working on bin-FP-math imprecisions, and was pointed by Steven D’Aprano that python is doing a good job - from a decimal POV - in rounding >>> round(0.30000000000000004, 16) 0.3 https://mail.gnome.org/archives/gnumeric-list/2021-July/msg00019.html ( where standard FP algorithms fail to 0.3000000000000001 reg. scaling up =0.30000000000000004 by 10^16 → 3000000000000000.5 ) searching in the forum I found th...
🌐
Mimo
mimo.org › glossary › python › round-function
Python round(): Rounding Numbers in Python
If precision is critical, Python’s decimal module provides a way to avoid floating-point precision issues. The decimal module allows you to work with decimal numbers while avoiding the rounding errors of float numbers. ... from decimal import Decimal, ROUND_HALF_UP # Create Decimal objects instead of using floats num = Decimal('2.675') # Use the quantize() method to round to two decimal places with rounding mode ROUND_HALF_UP rounded_num = num.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP) print(rounded_num) # Outputs: 2.68
🌐
Note.nkmk.me
note.nkmk.me › home › python
Round Up/Down Decimals in Python: math.floor, math.ceil | note.nkmk.me
January 15, 2024 - You can use round() to round half to even. Round numbers with round() and Decimal.quantize() in Python · To round up and down the elements in a NumPy array (ndarray), see the following article.