diff --git a/src/util/util.h b/src/util/util.h index aec42116b..7b69ec921 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -103,6 +103,7 @@ static inline unsigned next_power_of_two(unsigned v) { /** \brief Return the position of the most significant bit. */ +static inline unsigned log2(int v) { return std::bit_width((unsigned)v) - 1; } static inline unsigned log2(unsigned v) { return std::bit_width(v) - 1; } static inline unsigned log2(uint64_t v) { return std::bit_width(v) - 1; }