#27733 [NEW]: inaccurate arithmetic calculations
| From: | admin at rubas dot net | Date: | Sat, 27 Mar 2004 16:12:58 +0000 |
| Subject: | #27733 [NEW]: inaccurate arithmetic calculations | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-56950@lists.php.net to get a copy of this message | ||
From: admin at rubas dot net
Operating system: Linux 2.4.xx and 2.6.xx
PHP version: 4.3.4
PHP Bug Type: Math related
Bug description: inaccurate arithmetic calculations
Description:
------------
Sample Code:
<?php
$resultA = ((6 * 5.95) - (5.95 + 5.95 + 5.95 + 5.95 + 5.95 + 5.95));
$resultB = ((7 * 5.95) - (5.95 + 5.95 + 5.95 + 5.95 + 5.95 + 5.95 +
5.95));
echo "Result A: ".$resultA."\n";
echo "Result B: ".$resultB."\n";
?>
Output:
Result A: 0
Result B: -7.105427357601E-15
Reproduced with:
PHP 4.3.4
PHP 4.3.3
PHP 4.3.2
Reproduce code:
---------------
Sample Code:
<?php
$resultA = ((6 * 5.95) - (5.95 + 5.95 + 5.95 + 5.95 + 5.95 + 5.95));
$resultB = ((7 * 5.95) - (5.95 + 5.95 + 5.95 + 5.95 + 5.95 + 5.95 +
5.95));
echo "Result A: ".$resultA."\n";
echo "Result B: ".$resultB."\n";
?>
Expected result:
----------------
Result A: 0
Result B: 0
Actual result:
--------------
Result A: 0
Result B: -7.105427357601E-15
--
Edit bug report at http://bugs.php.net/?id=27733&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27733&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27733&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27733&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27733&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27733&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27733&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27733&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27733&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27733&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27733&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27733&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27733&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27733&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27733&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27733&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27733&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27733&r=float