[issue46467] Rounding 5, 50, 500 behaves differently depending on preceding value

2022-01-21 Thread Steven D'Aprano
Steven D'Aprano added the comment: As documented, this is not a bug. "if two multiples are equally close, rounding is done toward the even choice" https://docs.python.org/3/library/functions.html#round This is also called "Banker's Rounding" or "Round half to even" and for rounding many

[issue46467] Rounding 5, 50, 500 behaves differently depending on preceding value

2022-01-21 Thread Spencer Brown
Spencer Brown added the comment: This is intentional behaviour, if the value is 5 it rounds towards even as documented here: https://docs.python.org/3/library/functions.html#round The reason is so that if you have a bunch of random data, rounding won't slightly bias the result upward or

[issue46467] Rounding 5, 50, 500 behaves differently depending on preceding value

2022-01-21 Thread Adam Ulrich
New submission from Adam Ulrich : round(250,-2) returns 200 round(350,-2) returns 400 round(450,-2) returns 400 round(550,-2) returns 600 round(5,-1) returns 0 round(15,-1) returns 20 round(500,-3) returns 0 round(1500,-3) returns 2000 expected: round of 5 to consistently rounds up.