On Wednesday 13 December 2006 18:00, Dmitry Timoshkov wrote:
+static BOOL is_power_of_two(DWORD alignment) +{
- if (!alignment) return FALSE;
- while (!(alignment & 1))
- {
alignment >>= 1;
- }
- return alignment == 1;
+}
Although speed should not be an issue here, a faster way to test for a power of two is:
alignment && !(alignment & (alignment-1))
Bye,