http://qs321.pair.com?node_id=652444


in reply to Re: Exponential Function Programming
in thread Exponential Function Programming

$ret - $d != $ret is interesting. One would think it's the same as $d (in boolean context), but it isn't. By testing the effect of $d ($ret - $d != $ret) instead of $d itself, the loop can be ended sooner.
my $ret = 1; for my $d (1e-15, 1e-20) { printf("%g %d %d\n", $d, ( $d )?1:0, ( $ret-$d != $ret )?1:0, ); }
1e-015 1 1 # Often equivalent. 1e-020 1 0 # But not when there's an underflow.