From bc89eaf33a8dc01b9a723005b7941b0d465e57b6 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Fri, 28 Sep 2018 21:21:40 +0200 Subject: [PATCH] util-math: Fix is_power_of_two_loop for non-64-bit types --- source/util-math.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/util-math.h b/source/util-math.h index 6242c635..0364da96 100644 --- a/source/util-math.h +++ b/source/util-math.h @@ -91,7 +91,7 @@ namespace util { inline bool is_power_of_two_loop(T v) { bool have_bit = false; - for (size_t index = 63; index >= 0; index--) { + for (size_t index = 0; index < (sizeof(T) * 8); index++) { bool cur = (v & (1ull << index)) != 0; if (cur) { if (have_bit)