diff options
-rw-r--r-- | cross/android/arm/tryrun.cmake | 4 | ||||
-rw-r--r-- | cross/android/arm64/tryrun.cmake | 4 | ||||
-rw-r--r-- | cross/tryrun.cmake | 4 | ||||
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Math.cs | 18 | ||||
-rw-r--r-- | src/System.Private.CoreLib/shared/System/MathF.cs | 18 |
5 files changed, 30 insertions, 18 deletions
diff --git a/cross/android/arm/tryrun.cmake b/cross/android/arm/tryrun.cmake index 69b7158b4e..dc7523fc2e 100644 --- a/cross/android/arm/tryrun.cmake +++ b/cross/android/arm/tryrun.cmake @@ -7,11 +7,11 @@ SET( HAVE_COMPATIBLE_EXP_EXITCODE CACHE STRING "Result from TRY_RUN" FORCE) SET( HAVE_COMPATIBLE_ILOGB0_EXITCODE - 0 + 1 CACHE STRING "Result from TRY_RUN" FORCE) SET( HAVE_COMPATIBLE_ILOGBNAN_EXITCODE - 0 + 1 CACHE STRING "Result from TRY_RUN" FORCE) SET( REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE diff --git a/cross/android/arm64/tryrun.cmake b/cross/android/arm64/tryrun.cmake index 93a225009d..5e68f9d70a 100644 --- a/cross/android/arm64/tryrun.cmake +++ b/cross/android/arm64/tryrun.cmake @@ -3,11 +3,11 @@ SET( HAVE_COMPATIBLE_EXP_EXITCODE CACHE STRING "Result from TRY_RUN" FORCE) SET( HAVE_COMPATIBLE_ILOGB0_EXITCODE - 0 + 1 CACHE STRING "Result from TRY_RUN" FORCE) SET( HAVE_COMPATIBLE_ILOGBNAN_EXITCODE - 0 + 1 CACHE STRING "Result from TRY_RUN" FORCE) SET( REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE diff --git a/cross/tryrun.cmake b/cross/tryrun.cmake index 47aa7b4ba7..988a59c5f6 100644 --- a/cross/tryrun.cmake +++ b/cross/tryrun.cmake @@ -23,8 +23,8 @@ if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$") set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0) set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0) set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 0) - set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 0) + set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 1) + set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 1) set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0) set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0) set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0) diff --git a/src/System.Private.CoreLib/shared/System/Math.cs b/src/System.Private.CoreLib/shared/System/Math.cs index e278486775..af74185a88 100644 --- a/src/System.Private.CoreLib/shared/System/Math.cs +++ b/src/System.Private.CoreLib/shared/System/Math.cs @@ -658,15 +658,18 @@ namespace System } // We do this comparison first and separately to handle the -0.0 to +0.0 comparision - // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would + // * Doing (ax < ay) first could get transformed into (ay >= ax) by the JIT which would // then return an incorrect value - if (x == y) + double ax = Abs(x); + double ay = Abs(y); + + if (ax == ay) { return double.IsNegative(x) ? y : x; } - return (Abs(x) < Abs(y)) ? y : x; + return (ax < ay) ? y : x; } [NonVersionable] @@ -803,15 +806,18 @@ namespace System } // We do this comparison first and separately to handle the -0.0 to +0.0 comparision - // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would + // * Doing (ax < ay) first could get transformed into (ay >= ax) by the JIT which would // then return an incorrect value - if (x == y) + double ax = Abs(x); + double ay = Abs(y); + + if (ax == ay) { return double.IsNegative(x) ? x : y; } - return (Abs(x) < Abs(y)) ? x : y; + return (ax < ay) ? x : y; } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/System.Private.CoreLib/shared/System/MathF.cs b/src/System.Private.CoreLib/shared/System/MathF.cs index 428f9f88be..3bff55daeb 100644 --- a/src/System.Private.CoreLib/shared/System/MathF.cs +++ b/src/System.Private.CoreLib/shared/System/MathF.cs @@ -206,15 +206,18 @@ namespace System } // We do this comparison first and separately to handle the -0.0 to +0.0 comparision - // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would + // * Doing (ax < ay) first could get transformed into (ay >= ax) by the JIT which would // then return an incorrect value - if (x == y) + float ax = Abs(x); + float ay = Abs(y); + + if (ax == ay) { return float.IsNegative(x) ? y : x; } - return (Abs(x) < Abs(y)) ? y : x; + return (ax < ay) ? y : x; } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -241,15 +244,18 @@ namespace System } // We do this comparison first and separately to handle the -0.0 to +0.0 comparision - // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would + // * Doing (ax < ay) first could get transformed into (ay >= ax) by the JIT which would // then return an incorrect value - if (x == y) + float ax = Abs(x); + float ay = Abs(y); + + if (ax == ay) { return float.IsNegative(x) ? x : y; } - return (Abs(x) < Abs(y)) ? x : y; + return (ax < ay) ? x : y; } [Intrinsic] |