diff --git a/lib/aruba/contracts/is_power_of_two.rb b/lib/aruba/contracts/is_power_of_two.rb index adfd739e..6d0a449a 100644 --- a/lib/aruba/contracts/is_power_of_two.rb +++ b/lib/aruba/contracts/is_power_of_two.rb @@ -15,7 +15,7 @@ class IsPowerOfTwo 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? + value.positive? && value.nobits?(value - 1) rescue StandardError false end