Skip to content

Trailing zeroes in printed numbers #114

@lpbak

Description

@lpbak

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions