|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27119 wrong sum result
Submitted: 2004-02-02 01:11 UTC Modified: 2004-02-02 02:21 UTC
From: gnz at amorfo dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: 4.3.4 OS: Windows/Linux
Private report: No CVE-ID: None
 [2004-02-02 01:11 UTC] gnz at amorfo dot com
Hi, Im getting the wrong result performing a simple sum operation.
Ive been able to reproduce this on 
Windows with PHP 4.3.4
Windows with PHP 4.3.5 RC1
Linux with PHP 4.3.2

Reproduce code:

$a = 10.95;
$b = 11;
$c = $b-$a;

echo $c;


Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-02 02:21 UTC]
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.
Thank you for your interest in PHP.

try bcmath...
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 12 21:01:32 2024 UTC