cwMath.cpp : Fixed isPowerOfTwo() to recognize 1 as a power of 2.
This commit is contained in:
parent
4b08aeabde
commit
4619fc43a1
@ -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 )
|
||||||
|
Loading…
Reference in New Issue
Block a user