Re: json_decode/encode should return full precision values by default
| From: | Stanislav Malyshev | Date: | Tue, 28 Jul 2015 00:34:15 +0000 |
| Subject: | Re: json_decode/encode should return full precision values by default | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-87333@lists.php.net to get a copy of this message | ||
Hi!
>
> We can write
>
> $old = ini_set('precision', 17);
> json_encode($var);
> ini_set('precision', $old);
>
> everywhere to workaround this problem.
If we're talking about encoding, that's what precision setting is - it
says how much we want to preserve in decimal encoding of float numbers.
Decoding, of course, should use whatever data available and not
truncate, but I understand that is already happening?
> Question is "Is this the way it should be?".
I don't see why not. That's exactly what precision setting is for, as
far as I can see.
--
Stas Malyshev
smalyshev@gmail.com