APM: Perl zero not being zero, but 7e-12
Comrade Burnout
brian_clarkson at yahoo.com
Mon Sep 12 22:54:51 PDT 2005
i got bit by that once ... and i resorted to sprintf() ...
the floating point arithmetic is the root cause, i think.
--- Wayne Walker <wwalker at bybent.com> wrote:
> Number::Tolerant seems to be one way, but YECH.
>
> On Mon, Sep 12, 2005 at 10:46:23AM -0500, David Bluestein II wrote:
> > 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
> >
> >
> -----------------------------------------------------------------------
> > David H. Bluestein II
> > President & Lead Developer dbii at interaction.net
> > ii, inc.
> > http://www.interaction.net
> > -- Specializing in Interactive, Database Driven Websites --
> >
> > _______________________________________________
> > Austin mailing list
> > Austin at pm.org
> > http://mail.pm.org/mailman/listinfo/austin
>
> --
>
> Wayne Walker
>
> wwalker at bybent.com Do you use Linux?!
> http://www.bybent.com Get Counted!
> http://counter.li.org/
> Perl - http://www.perl.org/ Perl User Groups -
> http://www.pm.org/
> Jabber: wwalker at jabber.gnumber.com AIM: lwwalkerbybent
> IRC: wwalker on freenode.net
> _______________________________________________
> Austin mailing list
> Austin at pm.org
> http://mail.pm.org/mailman/listinfo/austin
>
i'm trying to get away from this mail account as much as possible. it's become a spamtrap.
please reply to , or update your address books to, geektron at comradeburnout.com
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
More information about the Austin
mailing list