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 steven.daprano
Recipients lazarillo, r.david.murray, steven.daprano
Date 2016-10-25.23:45:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1477439127.69.0.659943947877.issue28535@psf.upfronthosting.co.za>
In-reply-to
Content
To be clear, let's look at the first failed assertion:

AssertionError: 32.78 != 32.775 within 2 places

It sure *looks* like 32.775 ought to round to 32.78. And indeed it would, if it actually was 32.775. But despite appearances, it isn't. Sure, the number prints as 32.775, but that's a recent feature (and a mixed blessing at that). That's a side-effect of a clever (perhaps too clever) change to the way floats are printed, to prefer neat, friendly numbers over accuracy.

Before Python 2.7, the exact same float would have been printed as 32.774999999999999, and now its obvious why it rounds down to 32.77 rather than up to 32.78: 32.774999999999999 is *less* than 32.775.

To be precise, printing the old way:

32.774999999999999 rounds down to 32.770000000000003 rather than up to 32.780000000000001, exactly as promised.
History
Date User Action Args
2016-10-25 23:45:27steven.dapranosetrecipients: + steven.daprano, r.david.murray, lazarillo
2016-10-25 23:45:27steven.dapranosetmessageid: <1477439127.69.0.659943947877.issue28535@psf.upfronthosting.co.za>
2016-10-25 23:45:27steven.dapranolinkissue28535 messages
2016-10-25 23:45:27steven.dapranocreate