On 27/09/12 06:02, Mark Dickinson wrote:
On Wed, Sep 26, 2012 at 8:36 PM, M.-A. Lemburg<mal@egenix.com> wrote:
It's actually quite common in finance and time calculations to round to the nearest say basis point, cent or say micro second in calculations
That's exactly where the problems creep in, though. Naive users expect rounding to give 'correct' results for decimal halfway cases, and then are surprised when it doesn't.
round(2.675, 2) 2.67
So you end up explaining again and again that computing binary approximations to decimal rounds of binary approximations of decimal halfway cases is a bad idea.
Pretty much *everything* about binary floats is surprising to people who expect decimal semantics. Unless we're going to make Decimal the default floating point type, and shift binary floats to a module, I don't see any way around that, and a particularly don't see any reason to single round() out as more confusing than any of the other float gotchas. Speaking from my experience on the tutor@ and python-list@python.org mailing lists, I believe that problems with round are vanishingly rare, probably an order of magnitude fewer than "why doesn't Python add my two floats correctly?" type questions. -- Steven