Bug #69454 [Opn->Nab]: Linux

From: Date: Wed, 15 Apr 2015 01:22:22 +0000
Subject: Bug #69454 [Opn->Nab]: Linux
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192067@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69454&edit=1 ID: 69454 Updated by: requinix@php.net Reported by: gardist at gmail dot com Summary: Linux -Status: Open +Status: Not a bug Type: Bug Package: Variables related Operating System: Linux PHP Version: 5.5.23 Block user comment: N Private report: N New Comment: Floating point values have a limited precision. Hence a value might not have the same string representation after any processing. That also includes writing a floating point value in your script and directly printing it without any mathematical operations. If you would like to know more about "floats" and what IEEE 754 is, read this: http://www.floating-point-gui.de/ Thank you for your interest in PHP. round() the value. Previous Comments: ------------------------------------------------------------------------ [2015-04-15 01:16:31] gardist at gmail dot com Description: ------------ (2.4 - 2.4) must be 0! now it -8.8817841970013E-16 Test script: --------------- $m = 12; for($l=0; $l<12; $l++) { $m = $m - 2.4; echo "<br>".$l.": ".$m; } Expected result: ---------------- 0: 9.6 1: 7.2 2: 4.8 3: 2.4 4: 0 5: -2.4 6: -4.8 7: -7.2 8: -9.6 9: -12 10: -14.4 11: -16.8 Actual result: -------------- 0: 9.6 1: 7.2 2: 4.8 3: 2.4 4: -8.8817841970013E-16 5: -2.4 6: -4.8 7: -7.2 8: -9.6 9: -12 10: -14.4 11: -16.8 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69454&edit=1

« previous php.bugs (#192067) next »