From 8544cc15326dfc5947b4fb9046e493cfb2d761c7 Mon Sep 17 00:00:00 2001 From: jim winstead Date: Sun, 10 Mar 2002 23:46:43 +0000 Subject: [PATCH] handle numeric strings. this means we're less picky about the argument types, but the math functions aren't generally that picky. --- ext/standard/math.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ext/standard/math.c b/ext/standard/math.c index 7218fc74fc298..c66feabf7aabc 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -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;