@@ -746,7 +746,7 @@ public static explicit operator Half(float value)
746746 // Extract sign bit
747747 uint sign = ( bitValue & float . SignMask ) >> 16 ;
748748 // Detecting NaN (~0u if a is not NaN)
749- uint realMask = ( uint ) ( Unsafe . BitCast < bool , sbyte > ( float . IsNaN ( value ) ) - 1 ) ;
749+ uint realMask = float . IsNaN ( value ) ? 0u : ~ 0u ;
750750 // Clear sign bit
751751 value = float . Abs ( value ) ;
752752 // Rectify values that are Infinity in Half. (float.Min now emits vminps instruction if one of two arguments is a constant)
@@ -1075,17 +1075,15 @@ public static explicit operator float(Half value)
10751075 // Extract exponent bits of value (BiasedExponent is not for here as it performs unnecessary shift)
10761076 uint offsetExponent = bitValueInProcess & HalfExponentMask ;
10771077 // ~0u when value is subnormal, 0 otherwise
1078- uint subnormalMask = ( uint ) - Unsafe . BitCast < bool , byte > ( offsetExponent == 0u ) ;
1079- // ~0u when value is either Infinity or NaN, 0 otherwise
1080- int infinityOrNaNMask = Unsafe . BitCast < bool , byte > ( offsetExponent == HalfExponentMask ) ;
1078+ uint subnormalMask = offsetExponent == 0u ? ~ 0u : 0u ;
10811079 // 0x3880_0000u if value is subnormal, 0 otherwise
10821080 uint maskedExponentLowerBound = subnormalMask & ExponentLowerBound ;
10831081 // 0x3880_0000u if value is subnormal, 0x3800_0000u otherwise
10841082 uint offsetMaskedExponentLowerBound = ExponentOffset | maskedExponentLowerBound ;
10851083 // Match the position of the boundary of exponent bits and fraction bits with IEEE 754 Binary32(Single)
10861084 bitValueInProcess <<= 13 ;
10871085 // Double the offsetMaskedExponentLowerBound if value is either Infinity or NaN
1088- offsetMaskedExponentLowerBound <<= infinityOrNaNMask ;
1086+ offsetMaskedExponentLowerBound <<= offsetExponent == HalfExponentMask ? 1 : 0 ;
10891087 // Extract exponent bits and fraction bits of value
10901088 bitValueInProcess &= HalfToSingleBitsMask ;
10911089 // Adjust exponent to match the range of exponent
0 commit comments