diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs index 1effc397dc816b..61d2cf967b6a13 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/BFloat16.cs @@ -475,7 +475,7 @@ public static explicit operator BFloat16(double value) // Extract sign bit ulong sign = (bitValue & double.SignMask) >> 48; // Detecting NaN (~0u if a is not NaN) - ulong realMask = (ulong)(Unsafe.BitCast(double.IsNaN(value)) - 1); + ulong realMask = double.IsNaN(value) ? 0uL : ~0uL; // Clear sign bit value = double.Abs(value); // Rectify values that are Infinity in BFloat16. (float.Min now emits vminps instruction if one of two arguments is a constant)