APM: Perl zero not being zero, but 7e-12

David Bluestein II dbii at interaction.net
Mon Sep 12 08:46:23 PDT 2005

Okay, I've seen this before and have a question how to avoid it.

I take two variables:

$a= 38071.63;
$b = $i + $j; # Where $i + $j => 38071.63

print "$a : $b"; # results in 38071.63 : 38071.63

Yet if I do:

if ($a == $b) {
print "Equal";
} else {
print "Not equal";

I get a "Not equal".

If I subtract ($b-$a) the result is 7.27595761418343e-12. How do I get 
Perl to ignore this "noise" which comes from someplace?


David H. Bluestein II
President & Lead Developer         dbii at interaction.net
ii, inc.                                                  
     -- Specializing in Interactive, Database Driven Websites --

More information about the Austin mailing list