Class: Fixnum

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



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

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



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

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