php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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 ?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-15 08:49 UTC] derick@php.net
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.

Derick
 [2001-10-15 08:51 UTC] hholzgra@php.net
see also the note on floating point precision on
http://www.php.net/manual/en/language.types.float.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC