in reply to Re: Infinite loop but no reason why
in thread Infinite loop but no reason why
sub fp_equal { my ($X, $Y, $POINTS) = @_; my ($tX, $tY); $tX = sprintf("%.${POINTS}g", $X); $tY = sprintf("%.${POINTS}g", $Y); return $tX eq $tY; } fp_equal($x, $y, 3);
could be replaced with
sub fp_equal { return abs($_[0] - $_[1]) < $_[2]; } fp_equal($x, $y, 0.001);
Pros:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Infinite loop but no reason why
by jhourcle (Prior) on Jul 19, 2006 at 16:12 UTC | |
by ikegami (Patriarch) on Jul 19, 2006 at 17:18 UTC |