diff options
author | Zhi An Ng <zhin@google.com> | 2022-08-29 21:04:19 -0700 |
---|---|---|
committer | XNNPACK Team <xnnpack-github-robot@google.com> | 2022-08-29 21:05:42 -0700 |
commit | bb836fb415197caf8feed54bc7bb81d003608d2c (patch) | |
tree | ba8941b46398fd2f4fa632e7aa78364ac8a68223 | |
parent | 43e8a0710e25566cc819c539d73f01b182d0789a (diff) | |
download | XNNPACK-bb836fb415197caf8feed54bc7bb81d003608d2c.tar.gz |
Revert back to hex literal, guard with cpp check instead
There is no guarantee that compilers do correctly rounded conversion into binary
PiperOrigin-RevId: 470889342
-rw-r--r-- | src/xnnpack/math.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/xnnpack/math.h b/src/xnnpack/math.h index a2ee52fd0..b461ae219 100644 --- a/src/xnnpack/math.h +++ b/src/xnnpack/math.h @@ -303,6 +303,7 @@ XNN_INLINE static uint32_t math_rotl_u32(uint32_t x, int8_t r) #endif } +#ifndef __cplusplus XNN_INLINE static uint32_t math_cvt_sat_u32_f64(double x) { #if defined(__GNUC__) && defined(__arm__) float i; // float instead of uint32_t because vcvt.u32.f64 writes to an S register @@ -319,6 +320,7 @@ XNN_INLINE static uint32_t math_cvt_sat_u32_f64(double x) { #else x = math_max_f64(x, 0.0); x = math_min_f64(x, 4294967295.0); - return (uint32_t) double_as_uint64(x + 4503599627370496.0); // 0x1.0p+52 + return (uint32_t) double_as_uint64(x + 0x1.0p+52); #endif } +#endif |