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 mark.dickinson, qq100460045
Date 2018-08-05.07:58:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1533455934.31.0.56676864532.issue34337@psf.upfronthosting.co.za>
In-reply-to
Content
This isn't a bug: in short, you're evaluating a discontinuous function very close to a discontinuity; the errors inherent in floating-point arithmetic put you the "wrong" side of the discontinuity.

Or more simply, with binary floating-point, What You See Is Not What You Get. When you type 1.2, the value actually stored is the closest values that's exactly representable as a float, which turns out to be 1.1999999999999999555910790149937383830547332763671875. Similarly, the value actually stored for 0.2 is 0.200000000000000011102230246251565404236316680908203125. And 1.1999999999999999555910790149937383830547332763671875 % 0.200000000000000011102230246251565404236316680908203125 is 0.199999999999999900079927783735911361873149871826171875.

Some references:

https://docs.python.org/3/tutorial/floatingpoint.html
https://docs.python.org/3/reference/expressions.html#id17
History
Date User Action Args
2018-08-05 07:58:54mark.dickinsonsetrecipients: + mark.dickinson, qq100460045
2018-08-05 07:58:54mark.dickinsonsetmessageid: <1533455934.31.0.56676864532.issue34337@psf.upfronthosting.co.za>
2018-08-05 07:58:54mark.dickinsonlinkissue34337 messages
2018-08-05 07:58:54mark.dickinsoncreate