Why does Python 3 round half to even?

Python 2

round(3.5) => 4.0
round(4.5) => 5.0

Python 3

round(3.5) => 4
round(4.5) => 4

Mainly because:

  • to take away the round-up bias.
  • the result can be further divided by 2, and still an int

https://mathematica.stackexchange.com/questions/2116/why-round-to-even-integers

https://en.wikipedia.org/wiki/Rounding#Round_half_to_even

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s