Skip to content
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

from_str_radix_float gives incorrect (/imprecise) results on beta and nightly #25895

Closed
spaolacci opened this issue May 30, 2015 · 4 comments
Closed

Comments

@spaolacci
Copy link
Contributor

str::parse("2.99") correctly parses to 2.99 in stable branch, but less correctly to 2.9899999999999998 on both beta and nightly.

@sfackler
Copy link
Member

Is it parsing incorrectly or choosing a different representation when printing? 2.99 and 2.9899999999999998 have the same floating point representation. The floating to decimal logic was rewritten in #24612. cc @lifthrasiir

@lifthrasiir
Copy link
Contributor

@sfackler No, they have different floating point representations:

2.989999999999999769073610877967439591884613037109375 = 0x4007 eb85 1eb8 51eb
2.9899999999999998 (rounds down, also the shortest repr of above)
2.99 (rounds up, also the shortest repr of below)
2.9900000000000002131628207280300557613372802734375 = 0x4007 eb85 1eb8 51ec

This is very slight, but 2.99 should round up (absolute error of 2.13e-16 for up vs. 2.31e-16 for down) while it doesn't seem so. I believe this is more like #24557. cc @rprichard

@huonw
Copy link
Member

huonw commented May 31, 2015

Closing as a dupe of #24557. Thanks for filing.

@spaolacci
Copy link
Contributor Author

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants