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

Parse -0 as float -0.0 instead of integer 0 #801

Merged
merged 2 commits into from
Sep 14, 2021

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Sep 14, 2021

Fixes #799.

@dtolnay dtolnay merged commit d86e353 into serde-rs:master Sep 14, 2021
@dtolnay dtolnay deleted the negative0 branch September 14, 2021 20:12
@silverjam
Copy link

silverjam commented Sep 22, 2021

This seems to break a "round trip" of a 0 value (since it seams 0, not just -0 will get parsed as -0.0). We have a test that does a conversion from JSON -> typed structure then back to JSON, when we compare the reference JSON to the generated JSON we get a breakage because 0 is not equal to -0.

---- test_json2json stdout ----
input: "/home/ubuntu/dev/libsbp/test_data/roundtrip.json2json.output", output: "/home/ubuntu/dev/libsbp/test_data/test_json2json.output.third_transform"
value mismatch at line 0
json atoms at path ".acc[1]" are not equal:
    lhs:
        0

    rhs:
        -0.0

silverjam pushed a commit to swift-nav/libsbp that referenced this pull request Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Preserve sign on negative zero f32
2 participants