diff --git a/src/libraries/System.Private.CoreLib/src/System/Int128.cs b/src/libraries/System.Private.CoreLib/src/System/Int128.cs index 7a69db71674f47..241c1c39e71d55 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Int128.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Int128.cs @@ -425,7 +425,7 @@ public static explicit operator checked ulong(Int128 value) /// The value to convert. /// converted to a . [CLSCompliant(false)] - public static explicit operator UInt128(Int128 value) => Unsafe.BitCast(value); + public static explicit operator UInt128(Int128 value) => new UInt128(value._upper, value._lower); /// Explicitly converts a 128-bit signed integer to a value, throwing an overflow exception for any values that fall outside the representable range. /// The value to convert. @@ -438,7 +438,7 @@ public static explicit operator checked UInt128(Int128 value) { ThrowHelper.ThrowOverflowException(); } - return Unsafe.BitCast(value); + return new UInt128(value._upper, value._lower); } /// Explicitly converts a 128-bit signed integer to a value. diff --git a/src/libraries/System.Private.CoreLib/src/System/UInt128.cs b/src/libraries/System.Private.CoreLib/src/System/UInt128.cs index 7318f77480d0de..a37ec00c1b2809 100644 --- a/src/libraries/System.Private.CoreLib/src/System/UInt128.cs +++ b/src/libraries/System.Private.CoreLib/src/System/UInt128.cs @@ -344,7 +344,7 @@ public static explicit operator checked long(UInt128 value) /// The value to convert. /// converted to a . [CLSCompliant(false)] - public static explicit operator Int128(UInt128 value) => Unsafe.BitCast(value); + public static explicit operator Int128(UInt128 value) => new Int128(value._upper, value._lower); /// Explicitly converts a 128-bit unsigned integer to a value, throwing an overflow exception for any values that fall outside the representable range. /// The value to convert. @@ -357,7 +357,7 @@ public static explicit operator checked Int128(UInt128 value) { ThrowHelper.ThrowOverflowException(); } - return Unsafe.BitCast(value); + return new Int128(value._upper, value._lower); } /// Explicitly converts a 128-bit unsigned integer to a value.