Message361319
@mark.dickinson
> To be clear: the following is flawed as an accuracy test, because the *multiplication* by 1e9 introduces additional error.
Interesting, I completely missed that!
But did you notice that the full conversion might still perform better when using only floats?
```
>>> from fractions import Fraction as F
>>> r = 1580301619906185300
>>> abs(int(r / 1e9 * 1e9) - r)
84
>>> abs(round(F(r / 10**9) * 10**9) - r)
89
```
I wanted to figure out how often that happens so I updated my plotting, you can find the code and plot attached.
Notice how both methods seems to perform equally good (the difference of the absolute errors seems to average to zero). I have no idea about why that happens though. |
|
Date |
User |
Action |
Args |
2020-02-03 18:40:47 | vxgmichel | set | recipients:
+ vxgmichel, lemburg, rhettinger, mark.dickinson, vstinner, larry, stutzbach, serhiy.storchaka |
2020-02-03 18:40:47 | vxgmichel | set | messageid: <1580755247.09.0.523899281959.issue39484@roundup.psfhosted.org> |
2020-02-03 18:40:47 | vxgmichel | link | issue39484 messages |
2020-02-03 18:40:47 | vxgmichel | create | |
|