Did you get the + and - swapped? Now comp(5, 4.5, 1) is false and comp(5, 4.5, -1) is true.
Personally I prefer to use the good old standard mathematical way of expressing it:
if (abs($x - $y) <= $tolerance) { print "$x and $y are 'equal'"; }
lodin
In reply to Re^6: Why is Zero not 0?
by lodin
in thread Why is Zero not 0?
by jluther
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |