}
/* }}}*/
-/* {{{ proto int|float abs(int number)
+/* {{{ proto int|float abs(int|float number)
Return the absolute value of the number */
PHP_FUNCTION(abs)
{
}
/* }}} */
-/* {{{ proto float|false round(float number [, int precision [, int mode]])
+/* {{{ proto float round(float number [, int precision [, int mode]])
Returns the number rounded to specified precision */
PHP_FUNCTION(round)
{
double return_val;
ZEND_PARSE_PARAMETERS_START(1, 3)
- Z_PARAM_ZVAL(value)
+ Z_PARAM_NUMBER(value)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(precision)
Z_PARAM_LONG(mode)
places = precision;
#endif
}
- convert_scalar_to_number_ex(value);
switch (Z_TYPE_P(value)) {
case IS_LONG:
RETURN_DOUBLE(return_val);
break;
- default:
- RETURN_FALSE;
- break;
+ EMPTY_SWITCH_DEFAULT_CASE()
}
}
/* }}} */
// loop through each element of $inputs to check the behaviour of round()
$iterator = 1;
foreach($inputs as $input) {
- echo "\n-- Iteration $iterator --\n";
- var_dump(round($input, 14));
- $iterator++;
+ echo "\n-- Iteration $iterator --\n";
+ try {
+ var_dump(round($input, 14));
+ } catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+ }
+ $iterator++;
};
fclose($fp);
?>
===Done===
---EXPECTF--
+--EXPECT--
*** Testing round() : usage variations ***
-- Iteration 1 --
float(0)
-- Iteration 17 --
-float(0)
+round() expects parameter 1 to be int or float, string given
-- Iteration 18 --
-float(0)
+round() expects parameter 1 to be int or float, string given
-- Iteration 19 --
-bool(false)
+round() expects parameter 1 to be int or float, array given
-- Iteration 20 --
-float(0)
+round() expects parameter 1 to be int or float, string given
-- Iteration 21 --
-float(0)
+round() expects parameter 1 to be int or float, string given
-- Iteration 22 --
-float(0)
+round() expects parameter 1 to be int or float, string given
-- Iteration 23 --
-
-Notice: Object of class classA could not be converted to number in %s on line %d
-float(1)
+round() expects parameter 1 to be int or float, object given
-- Iteration 24 --
float(0)
float(0)
-- Iteration 26 --
-float(%f)
+round() expects parameter 1 to be int or float, resource given
===Done===