At 22:37 -0700 5/23/2001, Ed Silva wrote:
>This looks like a perl guru problem, as I cannot see how 0.03 != 0.03.

If you mean as in:

$a = 0.03;
$b = 0.06 - 0.02 - 0.01;
if ($a == $b) {
     print 'equal';
}
else {
     print "$a unequal $b";
}
print "\n\n";


john% perl /tmp/x3
0.03 unequal 0.03


In that sort of situation, it is floating point representation issues.
(None of the four constants making up $a and $b are representable
exactly...you can change the constants which total 0.03 in $b and get an
equal comparison.  Generally speaking, one should avoid equality tests on
computed floating point values...test for a "small enough" difference
instead.

  --John
-- 
John Baxter   [EMAIL PROTECTED]      Port Ludlow, WA, USA

Reply via email to