]> granicus.if.org Git - php/commitdiff
Bugfix. All tests pass now on my system
authorJeroen van Wolffelaar <jeroen@php.net>
Sat, 4 Aug 2001 18:29:37 +0000 (18:29 +0000)
committerJeroen van Wolffelaar <jeroen@php.net>
Sat, 4 Aug 2001 18:29:37 +0000 (18:29 +0000)
ext/standard/math.c

index 1a448ac02cda1fcd710bf0e8ef456f2985fb8284..378c206ff4c87d98827b84aaa0c82937bc7ceb86 100644 (file)
@@ -451,6 +451,7 @@ PHP_FUNCTION(pow)
 
        lbase = Z_LVAL_PP(zbase);
 
+       /* lexp != 0 */
        switch (lbase) {
                case -1:
                        RETURN_LONG( lexp & 1 ? -1 : 1 ); /* if lexp=odd ... */
@@ -464,6 +465,13 @@ PHP_FUNCTION(pow)
                        }
                case 1:
                        RETURN_LONG(1);
+               case LONG_MIN: /* special case since -LONG_MIN == 0 */
+                       /* lexp != 0, and only lexp==1 is LONG, DOUBLE otherwise */
+                       if (lexp == 1) {
+                               RETURN_LONG(LONG_MIN);
+                       } else {
+                               RETURN_DOUBLE(exp(log(-(double)LONG_MIN) * (double)lexp));
+                       }
                default:
                        /* abs(lbase) > 1 */
                        dval = exp(log((double) (lbase>0?lbase:-lbase)) *