From: [EMAIL PROTECTED]
Operating system: FreeBSD 4.4-STABLE
PHP version: 4.2.1
PHP Bug Type: Scripting Engine problem
Bug description: Identical float values are not identical when compared
This problem also occurs on PHP 4.1.2.
The following code fragment produces very odd results:
<?
$a = array(41.96, 20.97, 20.99);
$t = 0;
for($i = 1; $i < count($a); $i++)
$t += abs($a[$i]);
echo "$t != $a[0]\n";
var_dump($t != $a[0]);
echo "t = ";
var_dump($t);
echo "a[0] = ";
var_dump($a[0]);
?>
The results are shown below:
41.96 != 41.96
bool(true)
t = float(41.96)
a[0] = float(41.96)
Both variables appear to be the same type, and look the same, yet compare
incorrectly with both typed and untyped comparisons.
--
Edit bug report at http://bugs.php.net/?id=17282&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17282&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17282&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17282&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17282&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17282&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17282&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17282&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17282&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17282&r=globals