Vincent Michel <vxgmic...@gmail.com> added the comment:

@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.

----------
Added file: 
https://bugs.python.org/file48882/Comparing_conversions_over_5_us.png

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39484>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to