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

Fixed serialization for floating point values less than EPSILON. #372

Merged
merged 1 commit into from
Apr 1, 2022

Conversation

KirbyER
Copy link
Contributor

@KirbyER KirbyER commented Mar 30, 2022

Since EPSILON is defined as the difference between 1 and the next highest value, and values close to zero have higher precision, very small values were serialized with an extra ".0" e.g. "0.00000000000000005.0". These values then can't be properly deserialized. This fix compares the fractional part of the float to 0.0 instead of using EPSILON.

Fixes #374.

  • I've included my change in CHANGELOG.md

@juntyr
Copy link
Member

juntyr commented Mar 31, 2022

I found why the tests are failing in an unrelated way - for some reason \0 now gets printed as \0 instead of \u{0} (which was the case before), which is not yet supported. I'll add a quick fix so we can get this PR merged as well

Copy link
Member

@juntyr juntyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you file a short issue for this bug and then link that in a CHANGELOG entry? Otherwise, this looks good to me - thanks for catching the issue!

@juntyr juntyr self-assigned this Mar 31, 2022
@juntyr
Copy link
Member

juntyr commented Apr 1, 2022

Thanks for opening the issue @KirbyER! Could you rebase your branch and add the following line (or a better description) to the bottom of the unreleased section of the CHANGELOG:

- Fix issue [#374](https://github.com/ron-rs/ron/issues/374) extraneous .0 for small floats ([#372](https://github.com/ron-rs/ron/pull/372))

Thanks again for catching this bug and finding a fix!

Copy link
Collaborator

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense!

@KirbyER
Copy link
Contributor Author

KirbyER commented Apr 1, 2022

Sorry, got pulled away yesterday between opening the issue and updating the changelog. Done now. Thanks for sorting out the testing failure so quickly!

Copy link
Member

@juntyr juntyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@juntyr juntyr merged commit 366c1d8 into ron-rs:master Apr 1, 2022
torkleyy pushed a commit to torkleyy/ron that referenced this pull request Jun 6, 2022
…-rs#372)

Co-authored-by: KirbyER <7432155-KirbyER@users.noreply.gitlab.com>
@torkleyy torkleyy mentioned this pull request Jun 6, 2022
2 tasks
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.

Serialization error on very small floating point values
3 participants