diff options
Diffstat (limited to 'src/math/func.h')
-rw-r--r-- | src/math/func.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/math/func.h b/src/math/func.h index 413b5d9..98111c5 100644 --- a/src/math/func.h +++ b/src/math/func.h @@ -128,6 +128,12 @@ inline float Rand() return static_cast<float>(rand()) / static_cast<float>(RAND_MAX); } +//! Returns whether \a x is an even power of 2 +inline bool IsPowerOfTwo(unsigned int x) +{ + return x && !(x & (x - 1)); +} + //! Returns the next nearest power of two to \a x inline int NextPowerOfTwo(int x) { @@ -257,3 +263,4 @@ inline float Bounce(float progress, float middle = 0.3f, float bounce = 0.4f) } // namespace Math + |