]> granicus.if.org Git - php/commitdiff
handle numeric strings. this means we're less picky about the argument
authorjim winstead <jimw@php.net>
Sun, 10 Mar 2002 23:46:43 +0000 (23:46 +0000)
committerjim winstead <jimw@php.net>
Sun, 10 Mar 2002 23:46:43 +0000 (23:46 +0000)
types, but the math functions aren't generally that picky.

ext/standard/math.c

index 7218fc74fc298a4217f1f5499b4ab42bc5e05954..c66feabf7aabc58459cbb8ba71523057a124c47b 100644 (file)
@@ -429,14 +429,11 @@ PHP_FUNCTION(pow)
                return;
        }
 
-       /* TODO: handle numeric strings. */
-       if ((Z_TYPE_P(zbase) != IS_LONG && Z_TYPE_P(zbase) != IS_DOUBLE) ||
-               (Z_TYPE_P(zexp ) != IS_LONG && Z_TYPE_P(zexp ) != IS_DOUBLE)) {
-               php_error(E_WARNING, "Invalid argument(s) passed to %s()", get_active_function_name(TSRMLS_C));
-               RETURN_FALSE;
-       }
+       /* make sure we're dealing with numbers */
+       convert_scalar_to_number(zbase);
+       convert_scalar_to_number(zexp);
 
-       /* if both base and exponent were longs, try to get a long out */
+       /* if both base and exponent were longs, we'll try to get a long out */
        wantlong = Z_TYPE_P(zbase) == IS_LONG 
                && Z_TYPE_P(zexp ) == IS_LONG && Z_LVAL_P(zexp) >= 0;