Add deIsPowerOfTwo64
authorPyry Haulos <phaulos@google.com>
Fri, 11 Dec 2015 22:20:53 +0000 (14:20 -0800)
committerPyry Haulos <phaulos@google.com>
Fri, 11 Dec 2015 22:27:35 +0000 (14:27 -0800)
Change-Id: I2a3c40fe727c49f944e7608bc283eae4dd454dcc

framework/delibs/debase/deInt32.h

index 4806fe6..6550267 100644 (file)
@@ -206,6 +206,18 @@ DE_INLINE deBool deIsPowerOfTwo32 (int a)
 }
 
 /*--------------------------------------------------------------------*//*!
+ * \brief Check if a value is a power-of-two.
+ * \param a Input value.
+ * \return True if input is a power-of-two value, false otherwise.
+ *
+ * \note Also returns true for zero.
+ *//*--------------------------------------------------------------------*/
+DE_INLINE deBool deIsPowerOfTwo64 (deUint64 a)
+{
+       return ((a & (a - 1ull)) == 0);
+}
+
+/*--------------------------------------------------------------------*//*!
  * \brief Check if an integer is aligned to given power-of-two size.
  * \param a            Input value.
  * \param align        Alignment to check for.