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 Ultrasick, Zeev.Rotshtein, mark.dickinson
Date 2012-04-19.11:54:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1334836452.95.0.823863099523.issue5118@psf.upfronthosting.co.za>
In-reply-to
Content
> Well this IS a bug.

I assume that you're referring to behaviour like this:

Python 2.7.2 (default, Jan 13 2012, 17:11:09) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 2.545
>>> round(x, 2)
2.54

To explain again, what happens here is:

(1) After the assignment 'x = 2.545', what's stored for x is not the precise decimal value 2.545, but a binary approximation to it.  That binary approximation just happens to be very slightly less than 2.545.

(2) Now when rounding, the usual rules are applies (values less than half get rounded down), to give 2.54.

Which part(s) of the above do you think should be changed?  Should the 'round' function incorrectly round some numbers up even though they fall below the halfway case?
History
Date User Action Args
2012-04-19 11:54:12mark.dickinsonsetrecipients: + mark.dickinson, Ultrasick, Zeev.Rotshtein
2012-04-19 11:54:12mark.dickinsonsetmessageid: <1334836452.95.0.823863099523.issue5118@psf.upfronthosting.co.za>
2012-04-19 11:54:12mark.dickinsonlinkissue5118 messages
2012-04-19 11:54:12mark.dickinsoncreate