-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix bug in IsLong implementation #4655
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Relates: #4649 This commit fixes a bug in the IsLong implementation, and prefers reading long values over double values in PrimitiveObjectFormatter when the bytes represent a valid long value, to avoid floating point rounding errors that may happen when parsing a double from a long value. The bug in IsLong was that the loop over the array segment bytes was exiting early when the count of bytes was the same as long.Min/MaxValue length, and the current loop byte is less than the byte at index in long.Min/MaxValue. In this scenario, it should not exit early, but not continue to check following loop bytes against byte at index in long.Min/MaxValue. Following loop iterations still need to check whether remaining bytes are numbers.
Mpdreamz
approved these changes
Apr 22, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better fix then my initial patch 👍
Failing tests are:
|
github-actions bot
pushed a commit
that referenced
this pull request
Apr 22, 2020
Relates: #4649 This commit fixes a bug in the IsLong implementation, and prefers reading long values over double values in PrimitiveObjectFormatter when the bytes represent a valid long value, to avoid floating point rounding errors that may happen when parsing a double from a long value. The bug in IsLong was that the loop over the array segment bytes was exiting early when the count of bytes was the same as long.Min/MaxValue length, and the current loop byte is less than the byte at index in long.Min/MaxValue. In this scenario, it should not exit early, but not continue to check following loop bytes against byte at index in long.Min/MaxValue. Following loop iterations still need to check whether remaining bytes are numbers.
github-actions bot
pushed a commit
that referenced
this pull request
Apr 22, 2020
Relates: #4649 This commit fixes a bug in the IsLong implementation, and prefers reading long values over double values in PrimitiveObjectFormatter when the bytes represent a valid long value, to avoid floating point rounding errors that may happen when parsing a double from a long value. The bug in IsLong was that the loop over the array segment bytes was exiting early when the count of bytes was the same as long.Min/MaxValue length, and the current loop byte is less than the byte at index in long.Min/MaxValue. In this scenario, it should not exit early, but not continue to check following loop bytes against byte at index in long.Min/MaxValue. Following loop iterations still need to check whether remaining bytes are numbers.
russcam
added a commit
that referenced
this pull request
May 7, 2020
Relates: #4649 This commit fixes a bug in the IsLong implementation, and prefers reading long values over double values in PrimitiveObjectFormatter when the bytes represent a valid long value, to avoid floating point rounding errors that may happen when parsing a double from a long value. The bug in IsLong was that the loop over the array segment bytes was exiting early when the count of bytes was the same as long.Min/MaxValue length, and the current loop byte is less than the byte at index in long.Min/MaxValue. In this scenario, it should not exit early, but not continue to check following loop bytes against byte at index in long.Min/MaxValue. Following loop iterations still need to check whether remaining bytes are numbers. (cherry picked from commit f8c6940)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relates: #4649
This commit fixes a bug in the IsLong implementation, and prefers
reading long values over double values in PrimitiveObjectFormatter
when the bytes represent a valid long value, to avoid floating
point rounding errors that may happen when parsing a double from
a long value.
The bug in IsLong was that the loop over the array segment bytes was
exiting early when the count of bytes was the same as long.Min/MaxValue
length, and the current loop byte is less than the byte at index in
long.Min/MaxValue. In this scenario, it should not exit early, but
not continue to check following loop bytes against byte at index in
long.Min/MaxValue. Following loop iterations still need to check
whether remaining bytes are numbers.