in reply to Re^4: Why is Zero not 0?
in thread Why is Zero not 0?
$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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Why is Zero not 0?
by lodin (Hermit) on Feb 07, 2008 at 02:18 UTC | |
by Joost (Canon) on Feb 07, 2008 at 11:50 UTC |