Hi internals,
https://github.com/php/php-src/pull/5172 changes var_dump() to use
serialize_precision instead of precision to dump floating-point numbers.
To recap: serialize_precision defaults to -1, which will print exactly as
many floating-point digits as are needed to represent the number
accurately. precision defaults to 14, which will print a shorter but
potentially inaccurate float representation.
The motivation here is that var_dump() is debugging functionality and
should print values as accurately as possible. The single most common bug
report we receive is some kind of variation on:
$sum = 0.1 + 0.2;
var_dump($sum); // float(0.3)
var_dump($sum == 0.3); // bool(false) WTF???
After this change, this would instead be:
$sum = 0.1 + 0.2;
var_dump($sum); // float(0.30000000000000004)
var_dump($sum == 0.3); // bool(false) Makes sense...
I have little hope that developers will suddenly start understanding
floating-point numbers, but at least this should reduce the amount of
confusion.
Does anyone see an issue with doing this change?
Regards,
Nikita