[issue36082] The built-in round() function giving a wrong output

2019-02-22 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

This is called banker rounding and is done on purpose to limit the accumulation 
of errors when summing a list of rounded integers. You can read 
https://en.m.wikipedia.org/wiki/Rounding#Round_half_to_even and look at IEEE 
754 for more information.

--
nosy: +remi.lapeyre

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36082] The built-in round() function giving a wrong output

2019-02-22 Thread SilentGhost


SilentGhost  added the comment:

This is the documented behaviour. It might seem counter-intuitive, but it's is 
not likely to change.

--
nosy: +SilentGhost
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36082] The built-in round() function giving a wrong output

2019-02-22 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

https://docs.python.org/3/whatsnew/3.0.html

> The round() function rounding strategy and return type have changed. Exact 
> halfway cases are now rounded to the nearest even result instead of away from 
> zero. (For example, round(2.5) now returns 2 rather than 3.) round(x[, n]) 
> now delegates to x.__round__([n]) instead of always returning a float. It 
> generally returns an integer when called with a single argument and a value 
> of the same type as x when called with two arguments.

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36082] The built-in round() function giving a wrong output

2019-02-22 Thread Juho Pesonen


New submission from Juho Pesonen :

As the title says I have got some wrong outputs with the round() built-in 
function.
The bug occurs only with certain numbers though. (I've had problems only with 
the number 2.5, but I assume that there is more than one number that gives 
wrong output.)
Here are some outputs with the round built-in function:

>>>round(2.5)
2
>>>round(2.51)
3
>>>round(3.5)
4
>>>round(1.5)
2

As you can see the number 2.5 gives 2 instead of 3.

--
messages: 336329
nosy: Goodester
priority: normal
severity: normal
status: open
title: The built-in round() function giving a wrong output
type: behavior
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com