From 193dcc8c40ebf6375205a06830ccdd31a1f054ef Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sat, 4 Oct 2025 14:03:17 +0100 Subject: [PATCH] Remove unsafe `bool` casts --- .../System.Private.CoreLib/src/System/Numerics/BFloat16.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)