#27119 [Opn->Bgs]: wrong sum result
| From: | alan_k@php.net | Date: | Mon, 02 Feb 2004 07:21:59 +0000 |
| Subject: | #27119 [Opn->Bgs]: wrong sum result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-54275@lists.php.net to get a copy of this message | ||
ID: 27119
Updated by: alan_k@php.net
Reported By: gnz at amorfo dot com
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: Windows/Linux
PHP Version: 4.3.4
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.
Thank you for your interest in PHP.
try bcmath...
Previous Comments:
------------------------------------------------------------------------
[2004-02-02 01:11:26] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27119&edit=1