diff options
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/intmath.hh | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/base/intmath.hh b/src/base/intmath.hh index 0b22ba0db..ee5cf66c8 100644 --- a/src/base/intmath.hh +++ b/src/base/intmath.hh @@ -61,20 +61,6 @@ isPrime(const T& n) return true; } -template <class T> -inline T -leastSigBit(const T& n) -{ - return n & ~(n - 1); -} - -template <class T> -inline bool -isPowerOf2(const T& n) -{ - return n != 0 && leastSigBit(n) == n; -} - inline uint64_t power(uint32_t n, uint32_t e) { @@ -180,6 +166,13 @@ ceilLog2(const T& n) } template <class T> +inline bool +isPowerOf2(const T& n) +{ + return n != 0 && floorLog2(n) == ceilLog2(n); +} + +template <class T> inline T floorPow2(const T& n) { |