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.

Author mark.dickinson
Recipients ArneBab, mark.dickinson, r.david.murray, skrah
Date 2011-09-29.15:35:55
SpamBayes Score 0.0005472969
Marked as misclassified No
Message-id <1317310556.13.0.488632795491.issue13060@psf.upfronthosting.co.za>
In-reply-to
Content
> This is mathematically wrong ...

No, it's not 'mathematically wrong'.  There are many different rounding conventions in use, and no single universally agreed convention for rounding halfway cases.  Python chooses to use unbiased rounding[1] here, which matches the rounding used for all other basic arithmetic operations.

Other comments:

(1) I agree that round-half-up might be a useful convention to have available.  But...

(2) Depending on any sort of predictable rounding behaviour for *decimal* halfway cases when using *binary* floats is fraught with peril.  If you really care about these halfway cases going in a particular direction (whether it's away from zero, towards +infinity, towards even, towards odd, etc.) then you should really be using Decimal.







[1] http://en.wikipedia.org/wiki/Rounding#Round_half_to_even
History
Date User Action Args
2011-09-29 15:35:56mark.dickinsonsetrecipients: + mark.dickinson, r.david.murray, skrah, ArneBab
2011-09-29 15:35:56mark.dickinsonsetmessageid: <1317310556.13.0.488632795491.issue13060@psf.upfronthosting.co.za>
2011-09-29 15:35:55mark.dickinsonlinkissue13060 messages
2011-09-29 15:35:55mark.dickinsoncreate