cwMath.cpp : Fixed isPowerOfTwo() to recognize 1 as a power of 2.

This commit is contained in:
kevin 2024-04-30 19:52:40 -04:00
parent 4b08aeabde
commit 4619fc43a1

View File

@ -93,7 +93,7 @@ void cw::math::doubleToX80(double val, unsigned char rate[10])
bool cw::math::isPowerOfTwo( unsigned x ) bool cw::math::isPowerOfTwo( unsigned x )
{ {
return !( (x < 2) || (x & (x-1)) ); return x==1 || (!( (x < 2) || (x & (x-1)) ));
} }
unsigned cw::math::nextPowerOfTwo( unsigned val ) unsigned cw::math::nextPowerOfTwo( unsigned val )