$x could come in as -0.00 or -9.049848394839e-14.But you don't WANT -9.049848394839e-14 to be exactly equal to 0.
And that goes for any comparison between floats, which is why you need to specify your tolerance.
sub comp { my ($x,$y,$delta) = @_; $x -$delta >= $y && $x + $delta <= $y; }
In reply to Re^5: Why is Zero not 0?
by Joost
in thread Why is Zero not 0?
by jluther
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |