mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
both complex and rational are now builtin classes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2694b2f937
commit
6125552c27
16 changed files with 4952 additions and 1065 deletions
|
|
@ -127,7 +127,7 @@ class Rational
|
|||
if other.kind_of?(Rational)
|
||||
other2 = other
|
||||
if self < 0
|
||||
return Complex.new!(self, 0) ** other
|
||||
return Complex.__send__(:new!, self, 0) ** other
|
||||
elsif other == 0
|
||||
return Rational(1,1)
|
||||
elsif self == 0
|
||||
|
|
@ -175,7 +175,7 @@ class Rational
|
|||
num = 1
|
||||
den = 1
|
||||
end
|
||||
Rational.new!(num, den)
|
||||
Rational(num, den)
|
||||
elsif other.kind_of?(Float)
|
||||
Float(self) ** other
|
||||
else
|
||||
|
|
@ -187,7 +187,7 @@ class Rational
|
|||
def power2(other)
|
||||
if other.kind_of?(Rational)
|
||||
if self < 0
|
||||
return Complex(self, 0) ** other
|
||||
return Complex.__send__(:new!, self, 0) ** other
|
||||
elsif other == 0
|
||||
return Rational(1,1)
|
||||
elsif self == 0
|
||||
|
|
@ -219,7 +219,7 @@ class Rational
|
|||
num = 1
|
||||
den = 1
|
||||
end
|
||||
Rational.new!(num, den)
|
||||
Rational(num, den)
|
||||
elsif other.kind_of?(Float)
|
||||
Float(self) ** other
|
||||
else
|
||||
|
|
@ -306,4 +306,3 @@ end
|
|||
class Complex
|
||||
Unify = true
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue