Message323137
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 |
|
Date |
User |
Action |
Args |
2018-08-05 07:58:54 | mark.dickinson | set | recipients:
+ mark.dickinson, qq100460045 |
2018-08-05 07:58:54 | mark.dickinson | set | messageid: <1533455934.31.0.56676864532.issue34337@psf.upfronthosting.co.za> |
2018-08-05 07:58:54 | mark.dickinson | link | issue34337 messages |
2018-08-05 07:58:54 | mark.dickinson | create | |
|