So, this kind of behavior (as noted in comments), is a very traditional form of rounding, seen in the round half to even method. Also known (according to David Heffernan) as banker's rounding. The numpy documentation around this behavior implies that they are using this type of rounding, but also implies that there may be issues with the way in which numpy interacts with the IEEE floating point format. (shown below)

Notes
-----
For values exactly halfway between rounded decimal values, Numpy
rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0,
-0.5 and 0.5 round to 0.0, etc. Results may also be surprising due
to the inexact representation of decimal fractions in the IEEE
floating point standard [1]_ and errors introduced when scaling
by powers of ten.

Whether or not that is the case, I honestly don't know. I do know that large portions of the numpy core are still written in FORTRAN 77, which predates the IEEE standard (set in 1984), but I don't know enough FORTRAN 77 to say whether or not there's some issue with the interface here.

If you're looking to just round up regardless, the np.ceil function (ceiling function in general), will do this. If you're looking for the opposite (always rounding down), the np.floor function will achieve this.

Answer from Slater Victoroff on Stack Overflow
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: Round up/down array elements (np.floor, np.trunc, np.ceil) | note.nkmk.me
January 15, 2024 - The returned data type is a floating-point number (float). Use astype() to convert it to an integer (int). This also applies to np.trunc(), np.ceil(), etc. NumPy: Cast ndarray to a specific dtype with astype()
🌐
Medium
medium.com › @heyamit10 › how-to-round-numbers-to-integers-in-numpy-c43b43970c4c
How to Round Numbers to Integers in NumPy? | by Hey Amit | Medium
March 6, 2025 - This is because NumPy uses something called “banker’s rounding” or “round half to even”. Basically, when a number is exactly halfway between two integers (like 4.5), it rounds to the nearest even number. This reduces cumulative rounding errors in large datasets.
🌐
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.round.html
numpy.round — NumPy v2.1 Manual
Unless out was specified, a new array is created. A reference to the result is returned. The real and imaginary parts of complex numbers are rounded separately.
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: Round array elements (np.round, np.around, np.rint) | note.nkmk.me
January 15, 2024 - For example, if the original array is of type float, the rounded array will also be float, regardless of the number of decimal places. To convert the result to an integer (int), use astype() after np.round().
🌐
Programiz
programiz.com › python-programming › numpy › methods › floor
NumPy floor() (With Examples)
The floor() function rounds down each element in an array to the nearest smallest integer. import numpy as np array1 = np.array([1.9, 2.2, 3.1, 4.3])
Top answer
1 of 9
20

So, this kind of behavior (as noted in comments), is a very traditional form of rounding, seen in the round half to even method. Also known (according to David Heffernan) as banker's rounding. The numpy documentation around this behavior implies that they are using this type of rounding, but also implies that there may be issues with the way in which numpy interacts with the IEEE floating point format. (shown below)

Notes
-----
For values exactly halfway between rounded decimal values, Numpy
rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0,
-0.5 and 0.5 round to 0.0, etc. Results may also be surprising due
to the inexact representation of decimal fractions in the IEEE
floating point standard [1]_ and errors introduced when scaling
by powers of ten.

Whether or not that is the case, I honestly don't know. I do know that large portions of the numpy core are still written in FORTRAN 77, which predates the IEEE standard (set in 1984), but I don't know enough FORTRAN 77 to say whether or not there's some issue with the interface here.

If you're looking to just round up regardless, the np.ceil function (ceiling function in general), will do this. If you're looking for the opposite (always rounding down), the np.floor function will achieve this.

2 of 9
18

This is in fact exactly the rounding specified by the IEEE floating point standard IEEE 754 (1985 and 2008). It is intended to make rounding unbiased. In normal probability theory, a random number between two integers has zero probability of being exactly N + 0.5, so it shouldn't matter how you round it because that case never happens. But in real programs, numbers are not random and N + 0.5 occurs quite often. (In fact, you have to round 0.5 every time a floating point number loses 1 bit of precision!) If you always round 0.5 up to the next largest number, then the average of a bunch rounded numbers is likely to be slightly larger than the average of the unrounded numbers: this bias or drift can have very bad effects on some numerical algorithms and make them inaccurate.

The reason rounding to even is better than rounding to odd is that the last digit is guaranteed to be zero, so if you have to divide by 2 and round again, you don't lose any information at all.

In summary, this kind of rounding is the best that mathematicians have been able to devise, and you should WANT it under most circumstances. Now all we need to do is get schools to start teaching it to children.

🌐
NumPy
numpy.org › doc › stable › reference › generated › numpy.round.html
numpy.round — NumPy v2.4 Manual
Unless out was specified, a new array is created. A reference to the result is returned. The real and imaginary parts of complex numbers are rounded separately.
Find elsewhere
🌐
Medium
medium.com › @heyamit10 › understanding-numpy-round-up-ceil-vs-round-vs-floor-f155922395b8
Understanding NumPy Round Up (ceil vs round vs floor) | by Hey Amit | Medium
April 12, 2025 - np.round(): Rounds to the nearest integer (up or down based on standard rounding rules). You might be wondering: “Why does this matter?” Well, in practical scenarios — like calculating prices, dealing with coordinates, or ensuring buffer limits — you often need to force numbers up instead of relying on regular rounding. Let’s see how each of these functions works in action: import numpy as np arr = np.array([1.2, 2.5, 3.8, -4.3, -5.9]) # Rounding up (ceil) rounded_up = np.ceil(arr) # Regular rounding rounded_normal = np.round(arr) # Rounding down (floor) rounded_down = np.floor(arr) print("Original:", arr) print("Ceil (Round Up):", rounded_up) # [ 2.
🌐
Programiz
programiz.com › python-programming › numpy › methods › round
NumPy round() (With Examples)
If you prefer to have the output as integers without the decimal points, you can convert the data type of the rounded array to int using astype() as: rounded_array = np.round(array1).astype(int) Then the output will be, [[1 3 4] [4 6 6]] import numpy as np # create an array array1 = ...
🌐
Vultr Docs
docs.vultr.com › python › third-party › numpy › floor
Python Numpy floor() - Round Down Values | Vultr Docs
November 14, 2024 - The np.floor() function in NumPy is a powerful tool for number manipulation, allowing for efficient rounding down of various data types. It simplifies precise control over numeric data, particularly useful in fields like data science and financial ...
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-round-elements-of-the-numpy-array-to-the-nearest-integer
How to round elements of the NumPy array to the nearest integer? | GeeksforGeeks
June 8, 2022 - Our task is to convert all float-type values of Numpy array to their nearest array of integer values.Input: [1.2, 4.5, 9.1, 6.5, 8.9, 2.3, 1.2]Output: [1, 4, 9, 6, 8, 2,
🌐
Codecademy
codecademy.com › docs › python:numpy › math methods › .floor()
Python:NumPy | Math Methods | .floor() | Codecademy
May 14, 2025 - np.floor() rounds down to the nearest smallest integer (toward negative infinity).
🌐
Codecademy
codecademy.com › docs › python:numpy › ndarray › round()
Python:NumPy | ndarray | round() | Codecademy
October 29, 2025 - The round() method in NumPy rounds each element of an array to the nearest integer or to a specified number of decimal places.
🌐
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.round.html
numpy.round — NumPy v2.2 Manual
Unless out was specified, a new array is created. A reference to the result is returned. The real and imaginary parts of complex numbers are rounded separately.