Sha256: 0b116369efaa04e9ea7dba29a0fb05cd603a511a3f69f769c85af3b222b14f17
Contents?: true
Size: 526 Bytes
Versions: 30
Compression:
Stored size: 526 Bytes
Contents
require 'aruba/aruba_path' # Aruba module Aruba # Contracts module Contracts # Is value power of two class IsPowerOfTwo # Check value # # @param [Integer] value # The value to be checked 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 != 0 && (value & (value - 1)) == 0 ? true : false rescue false end end end end
Version data entries
30 entries across 30 versions & 3 rubygems