Bug #79355 [NEW]: number round + jscon_decode generate mistery numbers

From: Date: Sun, 08 Mar 2020 23:21:06 +0000
Subject: Bug #79355 [NEW]: number round + jscon_decode generate mistery numbers
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225955@lists.php.net to get a copy of this message
From: php at cylancer dot net Operating system: Debian Buster 64Bit PHP version: 7.3.15 Package: *Math Functions Bug Type: Bug Bug description:number round + jscon_decode generate mistery numbers Description: ------------ I use the PHP Version 7.3.14-1~deb10u1 After Json decoding, rounded numbers have many unexpected decimal places. Test script: --------------- $a = 4; $b = 6; $c = $a * 100 / $b; echo '$c = '. $c." \n\n"; $d = round($c, 1); // the second parameter is important echo '$d = round($c, 1);'."\n\n"; echo '$d = '.$d. ' <--- is rounded $c'."\n\n"; echo 'if i decode my result to json... '."\n\n"; echo json_encode($d)."\n\n"; echo 'then my number is not rounded.'."\n\n"; The output is: $c = 66.6666666667 $d = round($c, 1); $d = 66.7 <--- is rounded $c if i decode my result to json... 66.7000000000000028421709430404007434844970703125 then my number is not rounded. -- Edit bug report at https://bugs.php.net/bug.php?id=79355&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79355&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79355&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79355&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79355&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79355&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79355&r=support Expected behavior: https://bugs.php.net/fix.php?id=79355&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79355&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79355&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79355&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79355&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79355&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79355&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79355&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79355&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79355&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79355&r=mysqlcfg

« previous php.bugs (#225955) next »