Mr. Felix Mr. Felix - 2 months ago 5
PHP Question

PHP number more than 10 decimal places

I have this situation:

$a = (double)"8.876543456787654";
echo json_encode(["value" => $a]);

It's returning this:


And not this, which is the desirable:


Note that I can't have this:


How can I change this precision and cancel the rounding?


Set precision higher at runtime

ini_set("precision", "16");

Also use (float) instead of (double)