class Aruba::Contracts::IsPowerOfTwo
Is value power of two
def self.valid?(value)
-
value
(Integer
) --
def self.valid?(value) # explanation for algorithm can be found here: # http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/ value.positive? && (value & (value - 1)).zero? rescue StandardError false end