[php-src] Issue #8020: json_encode precision
| From: | nikic | Date: | Tue, 01 Feb 2022 20:32:41 +0000 |
| Subject: | [php-src] Issue #8020: json_encode precision | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-239418@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8020
Comment Author: nikic
JSON prints an exact representation of the floating-point number. You can use round() to round the
number in advance. If you are working with monetary value, it is strongly recommended to work with
integer rather than floating-point numbers to avoid precision issues.
It is also possible to adjust the serialize_precision ini setting, but I would recommend against
that.