fix parseNumber returning zero for finite values with negative exponent#2223
Open
sage-mode-hunter wants to merge 1 commit into
Open
fix parseNumber returning zero for finite values with negative exponent#2223sage-mode-hunter wants to merge 1 commit into
sage-mode-hunter wants to merge 1 commit into
Conversation
Owner
|
Thank you for this contribution. This is an interesting fix, but is it really useful? I looked at your user profile, and I found it rather peculiar. All of this is very suspicious and makes me question the real intent of this PR. Best regards, |
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
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.
Reading a numeric string as a number, for example
doc["x"].as<double>()onthe value "1" followed by 300 zeros and
e-30(which is 1e270), returns 0.exponent_offseteven when the exponent is negative, so a large positive offset combined with a negative exponent trips the guard and yields 0 instead of scaling the mantissa back down.exponent_maxis also too tight once the mantissa carries extra digits, which is why the check now uses the reach of the binary powers-of-ten table.Compute the effective exponent with its real sign and only saturate to inf/0 past what the table can represent;
multiplyByPowerOfTen()handles everything in range, including subnormals.