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 integer parsing correctness issues. #114

Merged
merged 1 commit into from
Sep 9, 2024
Merged

Fix integer parsing correctness issues. #114

merged 1 commit into from
Sep 9, 2024

Conversation

Alexhuszagh
Copy link
Owner

This avoids using an intermediary unsigned type and then post-overflow validation, which avoids issues with overflowing checks wrapping to above our min value. This does not meaningfully affect performance, despite simplifying the type checks dramatically. The float and integer parsing benchmarks are comparable to before, with the integer parsing being slower than core for simple integers but much faster for larger/random integers due to multi-digit parsing.

@Alexhuszagh Alexhuszagh added bug Something isn't working high priority High priority labels Sep 9, 2024
@Alexhuszagh Alexhuszagh added this to the 1.0 milestone Sep 9, 2024
@Alexhuszagh Alexhuszagh self-assigned this Sep 9, 2024
@Alexhuszagh
Copy link
Owner Author

I've also added the test cases provided and with the simpler overflow detection using checked_add/checked_sub and checked_mul for all flows, there's much less risk of an algorithm bug causing this to fail.

This avoids using an intermediary unsigned type and then post-overflow validation, which avoids issues with overflowing checks wrapping to above our min value. This does not meaningfully affect performance, despite simplifying the type checks dramatically. The float and integer parsing benchmarks are comparable to before, with the integer parsing being slower than core for simple integers but much faster for larger/random integers due to multi-digit parsing.

- Closes #91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority High priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Integer overflow checking logic is incorrect
1 participant