ID:               30018
 User updated by:  phpbug at javision dot de
 Reported By:      phpbug at javision dot de
-Status:           Bogus
+Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: linux
 PHP Version:      4.3.8
 New Comment:

i understand the rounding problem, but the bigger problem is that
402.83*1.16 returns 402.83 sometimes and sometimes it returns 467.2828.
so sometimes php multiplicates the number with 1.16 and sometimes it
doesn't


Previous Comments:
------------------------------------------------------------------------

[2004-09-08 00:26:11] [EMAIL PROTECTED]

Computers can only approximate floating point arithmetic to a given
precision level.  Read
http://de.php.net/manual/en/language.types.float.php


------------------------------------------------------------------------

[2004-09-07 23:32:09] phpbug at javision dot de

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 this bug report at http://bugs.php.net/?id=30018&edit=1

Reply via email to