1
0
mirror of https://github.com/php/php-src.git synced 2026-04-24 08:28:26 +02:00
Files
archived-php-src/ext/standard/tests/math/sqrt_variation.phpt
T
Nikita Popov a939805641 Use serialize_precision for var_dump()
var_dump() is debugging functionality, so it should print
floating-point numbers accurately. We do this by switching
to serialize_precision, which (by default) will print with
as much precision as necessary to preserve the exact value
of the float.

This also affects debug_zval_dump().

Closes GH-5172.
2020-02-25 09:51:32 +01:00

55 lines
986 B
PHP

--TEST--
Test variations in usage of sqrt()
--INI--
precision = 14
--FILE--
<?php
/*
* proto float sqrt(float number)
* Function is implemented in ext/standard/math.c
*/
//Test sqrt with a different input values
echo "*** Testing sqrt() : usage variations ***\n";
$values = array(23,
-23,
2.345e1,
-2.345e1,
0x17,
027,
"23",
"23.45",
"2.345e1",
"1000",
"1000ABC",
null,
true,
false);
for ($i = 0; $i < count($values); $i++) {
$res = sqrt($values[$i]);
var_dump($res);
}
?>
--EXPECTF--
*** Testing sqrt() : usage variations ***
float(4.795831523312719)
float(NAN)
float(4.8425200051213)
float(NAN)
float(4.795831523312719)
float(4.795831523312719)
float(4.795831523312719)
float(4.8425200051213)
float(4.8425200051213)
float(31.622776601683793)
Notice: A non well formed numeric value encountered in %s on line %d
float(31.622776601683793)
float(0)
float(1)
float(0)