Skip to content

Conversation

tannergooding
Copy link
Member

This resolves #98285

@ghost ghost assigned tannergooding Feb 15, 2024
@ghost ghost added the area-System.Numerics label Feb 15, 2024
@ghost
Copy link

ghost commented Feb 15, 2024

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

Issue Details

This resolves #98285

Author: tannergooding
Assignees: tannergooding
Labels:

area-System.Numerics

Milestone: -

}

return (bitCount - TSelf.One) ^ TSelf.Log2(value);
return TSelf.IsNegative(value) ? TSelf.Zero : ((bitCount - TSelf.One) ^ TSelf.Log2(value));
Copy link
Member Author

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"

Comment on lines +168 to +171
if (TSelf.IsNaN(value))
{
ThrowHelper.ThrowArithmeticException(SR.Arithmetic_NaN);
}
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

@tannergooding
Copy link
Member Author

Rerunning CI before merge.

@tannergooding
Copy link
Member Author

Logged #99942 to track the seemingly untracked issue. It's failing in other unrelated PRs like #98293. The other failures look to be tracked.

@tannergooding tannergooding merged commit 6f31582 into dotnet:main Mar 19, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2024
@tannergooding tannergooding deleted the fix-98285 branch July 1, 2025 14:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

INumber.Min(+QNaN, 1) returns 1
3 participants