Class: Bignum

Inherits:
Object
  • Object
show all
Defined in:
lib/long-decimal-extra.rb

Overview

to be removed again, but needed now to investigate problems with ./usr/lib/ruby/1.8/rational.rb:547: warning: in a**b, b may be too big

Instance Method Summary collapse

Instance Method Details

#rpower(other) ⇒ Object

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



453
454
455
456
457
458
459
460
461
462
# File 'lib/long-decimal-extra.rb', line 453

def rpower(other)
  if other >= 0
    self.power!(other)
  else
    r = Rational.new!(self, 1)
    raise TypeError, "other=#{other} must be integer" unless other.kind_of? Integer
    raise ArgumentError, "other=#{other} must not be too big" unless other.abs < LongMath::MAX_FLOATABLE
    r ** other
  end
end