Skip to content

#fmt float precision is busted #1610

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

Closed
brson opened this issue Jan 22, 2012 · 2 comments
Closed

#fmt float precision is busted #1610

brson opened this issue Jan 22, 2012 · 2 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Jan 22, 2012

#fmt("%.100f, 1.1) results in 1.1000000000

printf's results in 1.10000000000000008881784197001252323389053344726562500... etc.

@kud1ing
Copy link

kud1ing commented Jan 24, 2012

Maybe related to #1375?

@killerswan
Copy link
Contributor

I've done some messing around with float formatting here (#2488), and while I haven't found where, yet, there's some kind of 100 character cutoff...

Code:

io::println(#fmt("%.2f", 1.1));
io::println(#fmt("%.50f", 1.1));
io::println(#fmt("%.75f", 1.1));
io::println(#fmt("%.90f", 1.1));
io::println(#fmt("%.99f", 1.1));
io::println(#fmt("%.100f", 1.1));

Output:

1.10
1.10000000000000008881784197001252323389053344726563
1.100000000000000088817841970012523233890533447265625000000000000000000000000
1.100000000000000088817841970012523233890533447265625000000000000000000000000000000000000000
1.100000000000000088817841970012523233890533447265625000000000000000000000000000000000000000000000000
1.1000000000

@graydon graydon closed this as completed in 71bc267 Aug 9, 2012
Kobzol pushed a commit to Kobzol/rust that referenced this issue Dec 30, 2024
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

4 participants