|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13671 error of subtraction
Submitted: 2001-10-15 08:28 UTC Modified: 2001-10-15 08:51 UTC
From: c dot bolerichard at fabi dot fr Assigned:
Status: Not a bug Package: *Math Functions
PHP Version: 4.0.5 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: c dot bolerichard at fabi dot fr
New email:
PHP Version: OS:


 [2001-10-15 08:28 UTC] c dot bolerichard at fabi dot fr
These subtractions are false :

$r1 = 1.13 - 1.12;
$r2 = 1.12 - 1.13;

echo "$r1"; /* return : 0.0099999999999998 */
echo "$r2"; /* return : -0.0099999999999998 */

Why ?


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-15 08:49 UTC]
They are fine, this is how floating point numbers work. You store ~1.12 and ~1.13, not exactly 1.12 and 1.13.
Not a bug.

 [2001-10-15 08:51 UTC]
see also the note on floating point precision on
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 16:01:32 2024 UTC