Sha256: 7a55d7cb97928280936fa781c1f65eef2b58b0eae6b6d3c5c41456732f582d99
Contents?: true
Size: 364 Bytes
Versions: 2
Compression:
Stored size: 364 Bytes
Contents
class << Math # :nodoc: def log2(n); log(n) / log(2); end end if RUBY_VERSION =~ /1\.8/ class Hash # :nodoc: alias :key :index end end class Integer # :nodoc: def power_of_2? Math::log2(self).to_i == Math::log2(self) end def closest_power_of_2(limit=32) self.upto(limit) do |i| return i if i.power_of_2? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ipaddress-0.7.5 | lib/ipaddress/extensions/extensions.rb |
ipaddress-0.7.0 | lib/ipaddress/extensions/extensions.rb |