php.net |  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
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: gnz at amorfo dot com
New email:
PHP Version: OS:

 

 [2004-02-02 01:11 UTC] gnz at amorfo dot com
Description:
------------
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:
---------------
<?php 

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

echo $c;

?>


Expected result:
----------------
0.05

Actual result:
--------------
0.050000000000001

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-02 02:21 UTC] alan_k@php.net
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 Oct 09 15:01:28 2024 UTC