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

fix ron & json serialization of large floats #106

Merged
merged 2 commits into from
Jun 22, 2024

Conversation

squaaawk
Copy link
Contributor

Currently for JSON and RON, nanoserde serializes large floats as integers when possible, and during deserialization first reads them as integers and later converts to a float. This leads to a bug when handling large numbers. For example, 1e30 is serialized as "1000000000000000000000000000000", which attempts to be deserialized as a u64 and errors with a positive overflow.

This PR changes float serialization to use the debug trait rather than the display trait, resulting in the representation "1e30" which is deserialized directly to a float.

@knickish
Copy link
Collaborator

Thanks for doing this, looks like a win all the way around

@knickish knickish merged commit 88d20bd into not-fl3:master Jun 22, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants