-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
floats are formatted incorrectly #779
Comments
For future reference: The problem goes deeper as Ruby 1.9.3 seems to provide higher precision for floats then Python and RPython do. Executing the following with Python 2.7.5
gives:
which is not the original value. I'm not sure if this means that topaz needs another float implementation then the rpython one. |
Both RPython and MRI use a C |
Ok :) So I'll dig deeper to see where this is coming from. |
Hm... I've found out that the erroneous digits already come from the C module doing the conversion Again for documentation so far, I did a quick check on the precision of double floats according to wikipedia shows that this is actually the correct rounding. The number 25852016738885247000000.0 lies between 2^74 and 2^75. According to the article this means the spacing between two correctly represented numbers is 2^n-52, so in our case it is 2^74-52 = 2^22. If i take (wrongNumber - correctNumber) / 2^22, I'll get -0.08, so it is in this range (wolfram with the calculation). So Python does the right thing for double precision. Remains the question what MRI is doing. :) |
So Ruby does use
Remains the question what MRI is doing when printing a float... |
The reason is that Ruby is using a custom float to string algorithm in Ok anyones call: Does this mean we should mimic the behavior of Ruby here? |
Probably we want to mimic it, unless it's a bug. On Mon, Aug 11, 2014 at 11:54 AM, codeZeilen [email protected]
"I disapprove of what you say, but I will defend to the death your right to |
… includes tests for floats < 0 which are also formatted incorrectly
The text was updated successfully, but these errors were encountered: