diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/mathn.rb | 2 |
2 files changed, 6 insertions, 0 deletions
@@ -1,3 +1,7 @@ +Tue Dec 23 15:46:43 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp> + + * lib/mathn.rb: Math.sqrt(NaN) should be NaN. [ruby-dev:37537] + Tue Dec 23 15:46:47 2008 Eric Hodel <drbrain@segment7.net> * gem_prelude.rb: Match full RubyGems behavior when a gem can't be found. diff --git a/lib/mathn.rb b/lib/mathn.rb index 48cb99f8c6..0241f578e9 100644 --- a/lib/mathn.rb +++ b/lib/mathn.rb @@ -134,6 +134,8 @@ module Math else Complex(x, -y) end + elsif a.respond_to?(:nan?) and a.nan? + a elsif a >= 0 rsqrt(a) else |