In Files

  • mrblib/numeric.rb

Parent

Methods

Included Modules

Float

Float

ISO 15.2.9

Public Instance Methods

<<(other) click to toggle source
 
               # File mrblib/numeric.rb, line 184
def << other
  n = self.to_i
  other = other.to_i
  if other < 0
    n >> -other
  else
    other.times { n *= 2 }
    n
  end
end
            
>>(other) click to toggle source

mruby special - since mruby integers may be upgraded to floats, floats should be compatible to integers.

 
               # File mrblib/numeric.rb, line 166
def >> other
  n = self.to_i
  other = other.to_i
  if other < 0
    n << -other
  else
    other.times { n /= 2 }
    if n.abs < 1
      if n >= 0
        0
      else
        -1
      end
    else
      n.to_i
    end
  end
end