Method: Fixnum#bit_length

Defined in:
lib/backports/2.1.0/fixnum/bit_length.rb

#bit_lengthObject



4
5
6
7
8
9
10
11
# File 'lib/backports/2.1.0/fixnum/bit_length.rb', line 4

def bit_length
  n = if self >= 0
    self + 1
  else
    -self
  end
  (0...8 * size).bsearch{|i| n <= (1 << i) }
end