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

Float parsing skips frac parsing if 0 is first digit after decimal #47

Closed
Solidsilver opened this issue May 2, 2022 · 0 comments · Fixed by #48
Closed

Float parsing skips frac parsing if 0 is first digit after decimal #47

Solidsilver opened this issue May 2, 2022 · 0 comments · Fixed by #48

Comments

@Solidsilver
Copy link
Contributor

Issue

The function normalFloat(_ input: inout Substring) does not correctly parse floats. After parsing the decimal, it calls decIntTextUTF8(_ utf8: inout Substring.UTF8View) again. This function checks to make sure the first digit is not zero. However, with the fractional component of floats this is allowed.

The result of this bug is that floats parsed that fit this condition (ex: 12.02, -325.0021) will return without the digits following the first 0, and those remaining digits will be left on input causing a parsing error.

Suggested solution:

Create a separate function to be called after the decimal which does not perform this first-digit zero-check.

@dduan dduan mentioned this issue May 2, 2022
@dduan dduan closed this as completed in #48 May 2, 2022
dduan pushed a commit that referenced this issue May 2, 2022
Added flag to skip 0-start check after decimal point
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 a pull request may close this issue.

1 participant