From 48dcf7ad36c88be62d6b2d06eed44b4045523b45 Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 17 Sep 2005 16:00:23 +0000 Subject: * lib/mathn.rb (Rational::inspect): should preserve original operand. [ruby-core:05806] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/mathn.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/mathn.rb') diff --git a/lib/mathn.rb b/lib/mathn.rb index ba8557cffc..19325f2996 100644 --- a/lib/mathn.rb +++ b/lib/mathn.rb @@ -135,6 +135,7 @@ class Rational def ** (other) if other.kind_of?(Rational) + other2 = other if self < 0 return Complex.new!(self, 0) ** other elsif other == 0 @@ -155,7 +156,7 @@ class Rational for elm in npd elm[1] = elm[1] * other if !elm[1].kind_of?(Integer) and elm[1].denominator != 1 - return Float(self) ** other + return Float(self) ** other2 end elm[1] = elm[1].to_i end @@ -163,7 +164,7 @@ class Rational for elm in dpd elm[1] = elm[1] * other if !elm[1].kind_of?(Integer) and elm[1].denominator != 1 - return Float(self) ** other + return Float(self) ** other2 end elm[1] = elm[1].to_i end -- cgit v1.2.3