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 float-parsing logic #46

Merged
merged 1 commit into from
Jun 7, 2021

Conversation

kaushalmodi
Copy link
Member

@kaushalmodi kaushalmodi commented Jun 7, 2021

With the float string representation fixed in Nim devel (See
nim-lang/Nim#18139), that uncovered a bug in
the logic for parsing float TOML values.

For e.g. to parse "foo = 0.123", internally, 0.1 + 0.02 + 0.003 was
done which would evaluate to 0.12300000000000001. Earlier
float stringification bug caused that value to print out as "0.123"
instead of "0.12300000000000001".

This is now fixed by using parseutils.parsefloat, which parses the
"0.123" float value as 0.123 and not 0.12300000000000001.

Fixes #45.

/cc @timotheecour Request to review this PR.

With the float string representation fixed in Nim devel (See
nim-lang/Nim#18139), that uncovered a bug in
the logic for parsing float TOML values.

For e.g. to parse "foo = 0.123", internally, 0.1 + 0.02 + 0.003 was
done which would evaluate to 0.12300000000000001. Earlier
float stringification bug caused that value to print out as "0.123"
instead of "0.12300000000000001".

This is now fixed by using parseutils.parsefloat, which parses the
"0.123" float value as 0.123 and not 0.12300000000000001.

Fixes NimParsers#45.
@PMunch
Copy link
Member

PMunch commented Jun 7, 2021

Thanks for fixing this, it was a remnant of the original parser that was bound to break at some point. Haven't had the time to run this PR through the test-suite for TOML by burnt-sushi, but it looks like it should work at least.

@kaushalmodi
Copy link
Member Author

@PMunch Thanks! nimble run_toml_test passes with this PR. So merging this.

@kaushalmodi kaushalmodi merged commit 385aaf5 into NimParsers:master Jun 7, 2021
@kaushalmodi kaushalmodi deleted the fix-float-parsing branch June 7, 2021 12:18
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.

Float parsing fails the toml-test when using Nim devel
3 participants