Bug #75254 [NEW]: json_encode float
| From: | 845861050 at qq dot com | Date: | Mon, 25 Sep 2017 13:11:18 +0000 |
| Subject: | Bug #75254 [NEW]: json_encode float | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-211350@lists.php.net to get a copy of this message | ||
From: 845861050 at qq dot com
Operating system: centos 6.5
PHP version: 7.1.9
Package: *General Issues
Bug Type: Bug
Bug description:json_encode float
Description:
------------
<?php
$a=1.2;
$b=1;
$c=$a-$b;
echo json_encode($c);
?>
php.ini : serialize_precision =-1
sometimes it echo 0.2 ; sometimes it echo 0.1999999999999996
Test script:
---------------
<?php
$a=1.2;
$b=1;
$c=$a-$b;
echo json_encode($c);
?>
php.ini : serialize_precision =-1
sometimes it echo 0.2 ; sometimes it echo 0.1999999999999996
Expected result:
----------------
sometimes it echo 0.2 ; sometimes it echo 0.1999999999999996
Actual result:
--------------
json_encode float error
--
Edit bug report at https://bugs.php.net/bug.php?id=75254&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75254&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75254&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75254&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75254&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75254&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75254&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75254&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75254&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75254&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75254&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75254&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75254&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75254&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75254&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75254&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75254&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75254&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75254&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75254&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75254&r=mysqlcfg