Class: Fixnum

Inherits:
Object
  • Object
show all
Defined in:
lib/rational.rb

Instance Method Summary collapse

Instance Method Details

#quo(other) ⇒ Object Also known as: rdiv

If Rational is defined, returns a Rational number instead of a Fixnum.



486
487
488
# File 'lib/rational.rb', line 486

def quo(other)
  Rational.new!(self,1) / other
end

#rpower(other) ⇒ Object Also known as: **

Returns a Rational number if the result is in fact rational (i.e. other < 0).



492
493
494
495
496
497
498
# File 'lib/rational.rb', line 492

def rpower (other)
  if other >= 0
    self.power!(other)
  else
    Rational.new!(self,1)**other
  end
end