# $Release Version: 0.5 $
# $Revision: 1.1.1.1.4.1 $
# $Date: 1998/01/16 12:36:05 $
# by Keiju ISHITSUKA(SHL Japan Inc.)
gcd *= as[0] ** [as[1], pair[1]].min
def Integer.from_prime_division(pd)
raise ZeroDivisionError if self == 0
while (value1, mod = value.divmod(prime)
break if prime * prime >= value
@counts.push @seed + @seed
format "%s/%s", numerator.inspect, denominator.inspect
if other.kind_of?(Rational)
return Complex.new!(self, 0) ** other
npd = numerator.prime_division
dpd = denominator.prime_division
if !elm[1].kind_of?(Integer) and elm[1].denominator != 1
return Float(self) ** other2
if !elm[1].kind_of?(Integer) and elm[1].denominator != 1
return Float(self) ** other2
num = Integer.from_prime_division(npd)
den = Integer.from_prime_division(dpd)
elsif other.kind_of?(Integer)
den = denominator ** other
num = denominator ** -other
den = numerator ** -other
elsif other.kind_of?(Float)
x , y = other.coerce(self)
if other.kind_of?(Rational)
return Complex(self, 0) ** other
x = self.denominator.to_f.to_i
neard = self.denominator.to_f ** (1.0/other.denominator.to_f)
if (neard**other.denominator == self.denominator)
nearn = self.numerator.to_f ** (1.0/other.denominator.to_f)
elsif other.kind_of?(Integer)
den = denominator ** other
num = denominator ** -other
den = numerator ** -other
elsif other.kind_of?(Float)
x , y = other.coerce(self)
abs = sqrt(a.real*a.real + a.image*a.image)
# if not abs.kind_of?(Rational)
# return a**Rational(1,2)
x = sqrt((a.real + abs)/Rational(2))
y = sqrt((-a.real + abs)/Rational(2))
# if !(x.kind_of?(Rational) and y.kind_of?(Rational))
# return a**Rational(1,2)
elsif a.kind_of?(Rational)
rsqrt(a.numerator)/rsqrt(a.denominator)
byte_a = [src & 0xffffffff]
while (src >= max) and (src >>= 32)
byte_a.unshift src & 0xffffffff
main = (main << 32) + elm
if main * 4 < side * side
applo = ((sqrt!(side * side + 4 * main) - side)/2.0).to_i + 1
applo = sqrt!(main).to_i + 1
while (x = (side + applo) * applo) > main
answer = (answer << 16) + applo