float qNaN = BitConverter.Int32BitsToSingle(0x7FC00000);
Console.WriteLine(float.Min(qNaN, 1));
Double/Single/Half.Min(+QNaN, 1) correctly returns NaN but INumber.Min not:
|
/// <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)
Double/Single/Half.Min(+QNaN, 1)correctly returns NaN butINumber.Minnot:runtime/src/libraries/System.Private.CoreLib/src/System/Numerics/INumber.cs
Lines 108 to 127 in 9699f39
(another issue: search
..inINumber.csto find a redundant dot)