|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-12-16 15:29 UTC] laruence@php.net
[2015-12-16 15:30 UTC] laruence@php.net
-Status: Open
+Status: Feedback
[2015-12-16 15:42 UTC] djbrainnrg at gmail dot com
-Status: Feedback
+Status: Open
[2015-12-16 15:42 UTC] djbrainnrg at gmail dot com
[2015-12-16 17:56 UTC] ab@php.net
-Status: Open
+Status: Not a bug
[2015-12-16 17:56 UTC] ab@php.net
[2015-12-16 18:18 UTC] djbrainnrg at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 20 12:00:02 2025 UTC |
Description: ------------ Floating number precision in PHP 7 seems to be buggy or at least different to PHP 5.6. A simple calculation with a periodic number see testscript. This happens not with all periodic numbers. In PHP 5.6.x this works fine and output "8.2" as expected. In PHP 7.x this does NOT work and always output "8.199999999999", doesn't matter if you use round() with precision or not. Test script: --------------- ini_set("precision", (PHP_INT_SIZE == 4) ? 14 : 16); $nr = 8 + (1/10) + (9/90); var_dump($nr, round($nr, 2)); Expected result: ---------------- "8.2" for the rounded result on all systems. Actual result: -------------- "8.1999999999999" also with round() called