#30018 [NEW]: multiplication bug (with float values)
| From: | phpbug at javision dot de | Date: | Tue, 07 Sep 2004 21:32:10 +0000 |
| Subject: | #30018 [NEW]: multiplication bug (with float values) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-65890@lists.php.net to get a copy of this message | ||
From: phpbug at javision dot de
Operating system: linux
PHP version: 4.3.8
PHP Bug Type: Scripting Engine problem
Bug description: multiplication bug (with float values)
Description:
------------
sometimes php doesn't multiplicate float values and cuts the position
after the decimal point
Reproduce code:
---------------
//$aRegs[2][0] = 402.83 (regex match from website)
echo "<pre>\n";
var_dump($aRegs[2][0]);
echo "</pre>\n";
$zahl = $aRegs[2][0];
echo "<pre>\n";
var_dump($zahl);
echo "</pre>\n";
$zahl1 = doubleval($zahl);
echo "<pre>\n";
var_dump($zahl1);
echo "</pre>\n";
$zahl2 = (1.16*$zahl1);
echo "<pre>\n";
var_dump($zahl2);
echo "</pre>\n";
$zahl3 = (1.10*$zahl2);
echo "<pre>\n";
var_dump($zahl3);
echo "</pre>\n";
Expected result:
----------------
float(402.83)
float(402.83)
float(402.83)
float(467.2828)
float(514.01108)
Actual result:
--------------
float(402)
float(402)
float(402)
float(402)
float(402)
--
Edit bug report at http://bugs.php.net/?id=30018&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30018&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30018&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30018&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30018&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30018&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30018&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30018&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30018&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30018&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30018&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30018&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30018&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30018&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30018&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30018&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30018&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30018&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30018&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30018&r=mysqlcfg