-
Notifications
You must be signed in to change notification settings - Fork 64
Closed
Description
While not required by JSON spec (I believe), it might be the desired behaviour for the following tests to pass:
#[test]
fn trailing_zeroes_int() {
let n = Number::from_parts(true, 100, -1);
assert_eq!(format!("{}", n), "10");
}
#[test]
fn trailing_zeroes_fp() {
let n = Number::from_parts(true, 100, -3);
assert_eq!(format!("{}", n), "0.1");
}
#[test]
fn trailing_zeroes_small_fp() {
let n = Number::from_parts(true, 100, -302);
assert_eq!(format!("{}", n), "1e-300");
}
Currently they fail with "10.0" != "10", "0.100" != "0.1", and "1.00e-300" != "1e-300" respectively.
Activity
lpbak commentedon Jul 1, 2017
There is a simple solution:
but it unfortunately has a non-negligible impact on benchmarks. On my machine, the following benchmarks:
go from
to
maciejhirsz commentedon Jul 3, 2017
I think a potential solution would be to change
from_parts
to always produce normalized numbers (so shifting the work from printing to constructing the type), and provide an unsafe variant of the function that doesn't do it, which could be used internally in the parser.