Class: Fixnum

Inherits:
Object show all
Defined in:
lib/backports/1.8.7/fixnum/div.rb,
lib/backports/2.4.0/fixnum/dup.rb,
lib/backports/1.8.7/fixnum/fdiv.rb,
lib/backports/2.1.0/fixnum/bit_length.rb

Instance Method Summary collapse

Instance Method Details

#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

#div(n) ⇒ Object



3
4
5
# File 'lib/backports/1.8.7/fixnum/div.rb', line 3

def div(n)
  (self / n).to_i
end

#dupObject



2
3
4
# File 'lib/backports/2.4.0/fixnum/dup.rb', line 2

def dup
  self
end

#fdiv(n) ⇒ Object



3
4
5
# File 'lib/backports/1.8.7/fixnum/fdiv.rb', line 3

def fdiv(n)
  to_f / n
end