Is Power of Two

From Director Online Wiki
Jump to: navigation, search
--/******
--* IS POWER OF TWO
--****
--* @Param  : 'x' <Integer>
--* @Return : ''  <Boolean>
--***/
on mIsPowerOfTwo( x )
  if Not(IntegerP(x)) then return( FALSE )  
  return( Not(bitAnd(abs(x), abs(x)-1)) - ((x = 0) OR (abs(x) = 1)) )
end
--*/