From: sheepman Date: 2005-09-17T23:27:38+09:00 Subject: Re: 5**(-1/2) gives incorrect results under mathn. Hi, The following patch will fix this problem. Index: lib/mathn.rb =================================================================== RCS file: /src/ruby/lib/mathn.rb,v retrieving revision 1.7 diff -1 -u -r1.7 mathn.rb --- lib/mathn.rb 19 Dec 2003 17:29:06 -0000 1.7 +++ lib/mathn.rb 17 Sep 2005 14:25:04 -0000 @@ -126,2 +126,3 @@ if other.kind_of?(Rational) + other2 = other if self < 0 @@ -146,3 +147,3 @@ if !elm[1].kind_of?(Integer) and elm[1].denominator != 1 - return Float(self) ** other + return Float(self) ** other2 end @@ -154,3 +155,3 @@ if !elm[1].kind_of?(Integer) and elm[1].denominator != 1 - return Float(self) ** other + return Float(self) ** other2 end On Sat, 17 Sep 2005 16:46:46 +0900 C Erler wrote: > With ruby 1.8.1, > > require 'mathn' > > p 5**(1/2) > p 5**0.5 > p 5**(-1/2) > p 5**-0.5 > > 2.23606797749979 > 2.23606797749979 > 2.23606797749979 > 0.447213595499958 > > -- sheepman / TAMURA Takashi sheepman@sheepman.sakura.ne.jp http://sheepman.parfait.ne.jp/