Class: Bignum

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



537
538
539
# File 'lib/rubysl/rational/rational.rb', line 537

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



543
544
545
546
547
548
549
# File 'lib/rubysl/rational/rational.rb', line 543

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