Sha256: 35feb43767f59ea0240b4992b60dc074f25560320d0533ea61ad0e593f36e064

Contents?: true

Size: 260 Bytes

Versions: 10

Compression:

Stored size: 260 Bytes

Contents

unless Fixnum.method_defined? :bit_length
  require 'backports/2.0.0/range/bsearch'
  class Fixnum
    def bit_length
      n = if self >= 0
        self + 1
      else
        -self
      end
      (0...8 * size).bsearch{|i| n <= (1 << i) }
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/backports-3.6.8/lib/backports/2.1.0/fixnum/bit_length.rb
backports-3.6.8 lib/backports/2.1.0/fixnum/bit_length.rb
backports-3.6.7 lib/backports/2.1.0/fixnum/bit_length.rb
backports-3.6.6 lib/backports/2.1.0/fixnum/bit_length.rb
backports-3.6.5 lib/backports/2.1.0/fixnum/bit_length.rb
backports-3.6.4 lib/backports/2.1.0/fixnum/bit_length.rb
backports-3.6.3 lib/backports/2.1.0/fixnum/bit_length.rb
backports-3.6.2 lib/backports/2.1.0/fixnum/bit_length.rb
backports-3.6.1 lib/backports/2.1.0/fixnum/bit_length.rb
backports-3.6.0 lib/backports/2.1.0/fixnum/bit_length.rb