-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 some generic math DIMs to have the correct behavior #98510
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a6a4038
Fix the test BinaryIntegerWrapper relational operators
tannergooding daeccd8
Make sure the IBinaryFloatingPointIeee754 has their DIMs covered by t…
tannergooding 56f2913
Fix some DIMs to do the correct behavior
tannergooding 318012c
Fix the TryConvertTo wrapper
tannergooding 731e58e
Ensure that TryConvertFrom handles the underlying T for the helper wr…
tannergooding e7c8c23
Minor test fix
tannergooding bb898e3
Update DimTests.GenericMath.cs
tannergooding f2f5250
Merge branch 'main' into fix-98285
tannergooding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,9 +118,14 @@ static virtual TSelf Min(TSelf x, TSelf y) | |
// otherwise returns the larger of the inputs. It | ||
// treats +0 as larger than -0 as per the specification. | ||
|
||
if ((x != y) && !TSelf.IsNaN(x)) | ||
if (x != y) | ||
{ | ||
return x < y ? x : y; | ||
if (!TSelf.IsNaN(x)) | ||
{ | ||
return x < y ? x : y; | ||
} | ||
|
||
return x; | ||
} | ||
|
||
return TSelf.IsNegative(x) ? x : y; | ||
|
@@ -160,6 +165,10 @@ static virtual int Sign(TSelf value) | |
{ | ||
if (value != TSelf.Zero) | ||
{ | ||
if (TSelf.IsNaN(value)) | ||
{ | ||
ThrowHelper.ThrowArithmeticException(SR.Arithmetic_NaN); | ||
} | ||
Comment on lines
+168
to
+171
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sign is supposed to throw for NaN (unlike CopySign which does not). It's a historical behavior/contract of the API. |
||
return TSelf.IsNegative(value) ? -1 : +1; | ||
} | ||
return 0; | ||
|
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Log2 throws for negative integer values, so we need to explicitly check "is negative"