Don't ask to ask, just ask | |
PerlMonks |
Re: float values and operatorsby itub (Priest) |
on Aug 11, 2004 at 21:33 UTC ( [id://382102]=note: print w/replies, xml ) | Need Help?? |
Rule #1 of floating-point computing in any language, not just Perl: Never compare two floating-point numbers with == or != (or expect >= et al. to work in the edge cases). Use a tolerance range instead. Other monks have already explained the cause behind this numerical imprecision.
For a detailed explanation, see Comparing floating point numbers
In Section
Seekers of Perl Wisdom
|
|