Class: Fixnum

Inherits:
Object
  • Object
show all
Defined in:
lib/rational.rb,
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 Float.



519
520
521
# File 'lib/rational.rb', line 519

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).



525
526
527
528
529
530
531
# File 'lib/rational.rb', line 525

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