ID:               27733
 Comment by:       j at bitron dot ch
 Reported By:      admin at rubas dot net
 Status:           Open
 Bug Type:         Math related
 Operating System: Linux 2.4.xx and 2.6.xx
 PHP Version:      4.3.4
 New Comment:

Other programming languages as for example C don't have such
inaccuracies in results of that simple calculations. According to the
IEEE standard for floating point arithmetic, the different programming
languages must not return different results on the same machine.


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

[2004-03-27 11:12:58] admin at rubas dot net

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

Reply via email to