-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
The following code:
fn main() {
println!("{}", 1.2999999999999999);
println!("{:?}", 1.2999999999999999);
println!("{:.3}", 1.2999999999999999);
println!("{:.*}", 5, 1.2999999999999999);
// aren't pretty too
println!("{:#}", 1.2999999999999999);
println!("{:#?}", 1.2999999999999999);
}
prints:
1.2999999999999998
1.2999999999999998
1.300
1.30000
1.2999999999999998
1.2999999999999998
C behaviour:
#include <stdio.h>
void main() {
double f = 1.2999999999999999999;
printf("%.14g", f);
}
prints:
1.3
With Rust everything works like f, but not like g.
Is that really no way to get behaviour like g option of printf
?
It's highly important feature for serialization libs.
rustc 1.6.0-nightly (8ca0acc 2015-10-28)
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.