diff options
Diffstat (limited to 'src/nvim/math.h')
-rw-r--r-- | src/nvim/math.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/nvim/math.h b/src/nvim/math.h index c88ce1e03d..0321d0c9c6 100644 --- a/src/nvim/math.h +++ b/src/nvim/math.h @@ -1,5 +1,14 @@ #pragma once +#include <stdbool.h> +#include <stdint.h> + +/// Check if number is a power of two +static inline bool is_power_of_two(uint64_t x) +{ + return x != 0 && ((x & (x - 1)) == 0); +} + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "math.h.generated.h" #endif |