summaryrefslogtreecommitdiffstats
path: root/lib/mathn.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-17 16:00:23 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-17 16:00:23 +0000
commitc1619b08fa74010941cec48ed62d3ebdf5dc13c9 (patch)
treed174e1c1da894e1b62b96ede899680931f74b167 /lib/mathn.rb
parent0933c7f44265d3f3d0bbc0c0409b67728d077659 (diff)
downloadruby-c1619b08fa74010941cec48ed62d3ebdf5dc13c9.tar.gz
ruby-c1619b08fa74010941cec48ed62d3ebdf5dc13c9.tar.xz
ruby-c1619b08fa74010941cec48ed62d3ebdf5dc13c9.zip
* lib/mathn.rb (Rational::inspect): should preserve original
operand. [ruby-core:05806] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/mathn.rb')
-rw-r--r--lib/mathn.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/mathn.rb b/lib/mathn.rb
index ba8557cff..19325f299 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