From ee4ce7ae496df6ab57e3632b5b93e5e5360e0b58 Mon Sep 17 00:00:00 2001 From: Yaxun Sam Liu Date: Thu, 7 Feb 2019 17:29:36 -0500 Subject: [PATCH] Fix nan() for windows --- include/hip/hcc_detail/math_functions.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/hip/hcc_detail/math_functions.h b/include/hip/hcc_detail/math_functions.h index 6374375491..8ac87425b9 100644 --- a/include/hip/hcc_detail/math_functions.h +++ b/include/hip/hcc_detail/math_functions.h @@ -899,6 +899,7 @@ __DEVICE__ inline double nan(const char* tagp) { +#if !_WIN32 union { double val; struct ieee_double { @@ -906,8 +907,7 @@ double nan(const char* tagp) uint32_t quiet : 1; uint32_t exponent : 11; uint32_t sign : 1; - } bits; - + } bits; static_assert(sizeof(double) == sizeof(ieee_double), ""); } tmp; @@ -917,6 +917,11 @@ double nan(const char* tagp) tmp.bits.mantissa = __make_mantissa(tagp); return tmp.val; +#else + uint64_t val = __make_mantissa(tagp); + val |= 0xFFF << 51; + return reinterpret_cast(val); +#endif } __DEVICE__ inline