From dfa24289437797cb9794ecea05cb2c710c6b99de Mon Sep 17 00:00:00 2001 From: Junekey Jeon Date: Fri, 8 Jan 2021 14:39:30 -0800 Subject: [PATCH] Fix an error in countr_zero (#11) --- include/dragonbox/dragonbox.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/dragonbox/dragonbox.h b/include/dragonbox/dragonbox.h index 937b058..34b9983 100644 --- a/include/dragonbox/dragonbox.h +++ b/include/dragonbox/dragonbox.h @@ -281,7 +281,7 @@ namespace jkj::dragonbox { template inline int countr_zero(UInt n) noexcept { static_assert(std::is_unsigned_v && value_bits <= 64); -#if (defined(__GNUC__) || defined(__clang__)) && defined(__x86_64__) +#if 0/*(defined(__GNUC__) || defined(__clang__)) && defined(__x86_64__) #define JKJ_HAS_COUNTR_ZERO_INTRINSIC 1 if constexpr (std::is_same_v) { return __builtin_ctzl(n); @@ -307,7 +307,7 @@ namespace jkj::dragonbox { else { static_assert(sizeof(UInt) <= sizeof(unsigned int)); return int(_tzcnt_u32((unsigned int)n)); - } + }*/ #else #define JKJ_HAS_COUNTR_ZERO_INTRINSIC 0 int count; @@ -345,6 +345,8 @@ namespace jkj::dragonbox { count = value_bits; } } + + n32 &= (0 - n32); if constexpr (value_bits > 16) { if ((n32 & 0x0000ffff) != 0) count -= 16; }