Nearest Down power of two

From Director Online Wiki
Jump to: navigation, search
--/******
--* NEAREST DOWN POWER OF TWO
--****
--* @Param  : 'x' <Integer>
--* @Return : ''  <Integer>
--***/
on mNearestDownPowerOfTwo( x )
  if Not(IntegerP(x)) then return( FALSE )
  return( integer(power(2, floor(log(x)/log(2)))) + (x <= 1) )
end
--*/