Fix issue 16026: std.math.frexp!float() wrong for very small subnormals#4337
Merged
dnadlinger merged 1 commit intodlang:masterfrom May 22, 2016
Merged
Fix issue 16026: std.math.frexp!float() wrong for very small subnormals#4337dnadlinger merged 1 commit intodlang:masterfrom
dnadlinger merged 1 commit intodlang:masterfrom
Conversation
Contributor
|
| tuple(-T.nan, -T.nan, int.min), | ||
|
|
||
| // Phobos issue #16026: | ||
| tuple(3 * (T.min_normal * T.epsilon), T( .75), (T.min_exp - T.mant_dig) + 2) |
Member
There was a problem hiding this comment.
Does the issue need to be included with the test?
Contributor
Author
There was a problem hiding this comment.
Well, it's just a comment, so obviously it doesn't need to be there. This is a common practice in the core dlang projects though: to label tests with the issue number that precipitated their inclusion.
Two main benefits I see:
- Seeing issue labels like this scattered throughout the tests provides real-world evidence to people browsing the code about what kind of test cases are needed for full coverage of related algorithms. Without that feedback, it is hard to know when to stop adding test cases.
- For anyone tempted to reduce the number of test cases while refactoring, or while trying to speed up the test suite, it says, "Don't remove this one!"
Member
There was a problem hiding this comment.
No one should be removing tests though if they want to keep the coverage. ;-)
Member
|
Looks fine |
Contributor
Author
|
@9il Can we pull this? It's just a tiny bug fix. |
Contributor
|
Auto-merge toggled on |
Contributor
Author
|
@klickverbot Thanks. |
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.
This PR fixes Phobos issue #16026:
std.math.frexp!float()andstd.math.frexp!double()return a wrong significand for subnormal values.The problem turns out to be a wrong "magic number"
0x8000which selects which values of the highest 16 bits should be preserved while manually changing the exponent using bitwise operations. The correct value is~F.EXPMASK, which happens to equal0x8000for the 80-bit and 128-bit IEEE formats, but not for 32- or 64-bit.(Ultimately, I intend to replace the entire
frexp()implementation with a clearer and more concise one based onRealRep, but I realize that it may take a while to get such a large change pulled, so I thought I'd submit this quick fix in the mean time.)