Re: json_decode/encode should return full precision values by default
| From: | Yasuo Ohgaki | Date: | Tue, 28 Jul 2015 00:39:38 +0000 |
| Subject: | Re: json_decode/encode should return full precision values by default | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-87334@lists.php.net to get a copy of this message | ||
Hi all,
On Tue, Jul 28, 2015 at 9:34 AM, Stanislav Malyshev <smalyshev@gmail.com>
wrote:
> >
> > 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.
JSON is var exporter/importer like serialize/var_export.
Both of serialize/var_export uses PG(serialize_precision), what's the point
of
_lose_ / _destroy_ original values while PHP could keep more precise values
than now?
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net