From 039697860b0985bfaecd4e6d37e2968516daad9d Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Thu, 15 Aug 2024 08:24:58 -0400 Subject: [PATCH] =?UTF-8?q?Revert=20"Use=20`Unsafe.BitCast`=20for=20`Int12?= =?UTF-8?q?8`=20=E2=86=94`UInt128`=20operators=20(#104506)"=20(#106430)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 01dbf511d03f17bff6ac3effc4c5aabaa597cf74. --- src/libraries/System.Private.CoreLib/src/System/Int128.cs | 4 ++-- src/libraries/System.Private.CoreLib/src/System/UInt128.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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.