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 mantissa overflow for denormal inputs #170

Merged
merged 1 commit into from
Jun 5, 2020
Merged

Conversation

abolz
Copy link
Contributor

@abolz abolz commented Jun 5, 2020

The numbers in the test case all should round up to the smallest normalized
single-precision number. Previously they were all flushed to zero because
rounding up overflows the mantissa and only the lower 23 bits were used.

This patch modifies the existing overflow check to also check for the
condition described above.


NB:

With this patch, the s2f function correctly parses all 9-digit inputs in the form 0.00000000e-46, 0.00000001e-46, ... 9.99999999e+38. (Where correctly is defined as returning the same binary number as the double-conversion library.)

The numbers in the test case all should round up to the smallest normalized
single-precision number. Previously they were all flushed to zero because
rounding up overflows the mantissa and only the lower 23 bits were used.

This patch modifies the existing overflow check to also check for the
condition described above.
@ulfjack ulfjack self-requested a review June 5, 2020 15:56
@ulfjack ulfjack merged commit 5fcc341 into ulfjack:master Jun 5, 2020
@ulfjack
Copy link
Owner

ulfjack commented Jun 5, 2020

Not sure why Travis didn't post the test results - everything worked.

@abolz abolz deleted the overflow branch June 6, 2020 07:25
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.

None yet

2 participants