From 2f2900ed625ee14d5ceed128ebb518619a05bfba Mon Sep 17 00:00:00 2001 From: Hyeongseok Oh Date: Tue, 16 Aug 2016 19:22:06 +0900 Subject: [PATCH] fix for correct conversion from negative double to unsigned long in ARM Commit migrated from https://github.com/dotnet/coreclr/commit/fdf58bc1b0e3906c5a3fba0017ea8f2f9887a892 --- src/coreclr/src/vm/jithelpers.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/coreclr/src/vm/jithelpers.cpp b/src/coreclr/src/vm/jithelpers.cpp index 1626810..1f7c630 100644 --- a/src/coreclr/src/vm/jithelpers.cpp +++ b/src/coreclr/src/vm/jithelpers.cpp @@ -588,8 +588,17 @@ FORCEINLINE INT64 FastDbl2Lng(double val) FCALL_CONTRACT; return HCCALL1_V(JIT_Dbl2Lng, val); #else +// In x86/x64, conversion result of negative double to unsigned integer is +// bit-equivalent unsigned value. +// But other architecture's compiler convert negative doubles to zero when +// the target is unsigned. +#ifdef _TARGET_XARCH_ FCALL_CONTRACT; return((__int64) val); +#else + FCALL_CONTRACT; + return((unsigned __int64) val); +#endif #endif } -- 2.7.4