in reply to Re^2: Equality checking for strings AND numbers
in thread Equality checking for strings AND numbers
when comparing numbers, I tend to avoid using == to go for something like:
sub equality{ my ($a, $b, $eps) = @_; abs( $a-$b ) < $eps ? return 1: return 0; }
where $eps is the desired precision
Cheers,
lin0
|
---|
Replies are listed 'Best First'. | |
---|---|
Equality checking - Comparing floats
by halley (Prior) on Jul 13, 2007 at 14:42 UTC | |
by lin0 (Curate) on Jul 13, 2007 at 17:31 UTC | |
by Anonymous Monk on Jul 13, 2007 at 15:40 UTC |
In Section
Seekers of Perl Wisdom