diff options
| author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-16 00:23:43 +0000 |
|---|---|---|
| committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-16 00:23:43 +0000 |
| commit | 53ad47de80b64673d5e57924e08344dcf6f6f52a (patch) | |
| tree | 8f77bc1b34603f4ce939aa4b5a77f5e8303b7df4 /lib/mathn.rb | |
| parent | 0bed7f6c4fee2d176a235131d9613dd04d9f3f08 (diff) | |
| download | ruby-53ad47de80b64673d5e57924e08344dcf6f6f52a.tar.gz ruby-53ad47de80b64673d5e57924e08344dcf6f6f52a.tar.xz ruby-53ad47de80b64673d5e57924e08344dcf6f6f52a.zip | |
both complex and rational are now builtin classes.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/mathn.rb')
| -rw-r--r-- | lib/mathn.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/mathn.rb b/lib/mathn.rb index 724d37ea6..f3be55eb6 100644 --- a/lib/mathn.rb +++ b/lib/mathn.rb @@ -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 - |
