-
Couldn't load subscription status.
- Fork 5.2k
Closed
Labels
area-System.Numericsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
Description
float qNaN = BitConverter.Int32BitsToSingle(0x7FC00000);
Console.WriteLine(float.Min(qNaN, 1));Double/Single/Half.Min(+QNaN, 1) correctly returns NaN but INumber.Min not:
runtime/src/libraries/System.Private.CoreLib/src/System/Numerics/INumber.cs
Lines 108 to 127 in 9699f39
| /// <summary>Compares two values to compute which is lesser.</summary> | |
| /// <param name="x">The value to compare with <paramref name="y" />.</param> | |
| /// <param name="y">The value to compare with <paramref name="x" />.</param> | |
| /// <returns><paramref name="x" /> if it is less than <paramref name="y" />; otherwise, <paramref name="y" />.</returns> | |
| /// <remarks>For <see cref="IFloatingPoint{TSelf}" /> this method matches the IEEE 754:2019 <c>minimum</c> function. This requires NaN inputs to be propagated back to the caller and for <c>-0.0</c> to be treated as less than <c>+0.0</c>.</remarks> | |
| static virtual TSelf Min(TSelf x, TSelf y) | |
| { | |
| // This matches the IEEE 754:2019 `minimum` function | |
| // | |
| // It propagates NaN inputs back to the caller and | |
| // otherwise returns the larger of the inputs. It | |
| // treats +0 as larger than -0 as per the specification. | |
| if ((x != y) && !TSelf.IsNaN(x)) | |
| { | |
| return x < y ? x : y; | |
| } | |
| return TSelf.IsNegative(x) ? x : y; | |
| } |
(another issue: search .. in INumber.cs to find a redundant dot)
Metadata
Metadata
Assignees
Labels
area-System.Numericsin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged