Speculative fix for computing Math.pow(2, -1074) on win32 where
authorkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 18 Jun 2009 05:47:31 +0000 (05:47 +0000)
committerkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 18 Jun 2009 05:47:31 +0000 (05:47 +0000)
the overloaded pow(double, int) function from math.h produces the
wrong answer.

TBR=whesse@chromium.org
Review URL: http://codereview.chromium.org/131022

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2214 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/runtime.cc

index e645548..f6b604a 100644 (file)
@@ -4170,7 +4170,9 @@ static double powi(double x, int y) {
         // internal precision in the pow() implementation would have
         // given us a finite p. This happens very rarely.
         double result = 1.0 / p;
-        return (result == 0 && isinf(p)) ? pow(x, y) : result;
+        return (result == 0 && isinf(p))
+            ? pow(x, static_cast<double>(y))  // Avoid pow(double, int).
+            : result;
       } else {
         return p;
       }