![]() |
|
more useful options | |
PerlMonks |
Re: eq vs ==by moritz (Cardinal) |
on Nov 10, 2009 at 12:35 UTC ( #806207=note: print w/replies, xml ) | Need Help?? |
I think the difference that confuses you is that some numbers can be represented by floating points without any error, while others can't. For example 0.1 is an infinite fraction in the binary system.
So while you can safely compare 0.5 * 2.0 == 1.0, you can't safely compare 0.1 * 2.0 == 0.2 (the former is true, the latter false). The correct way to compare floating point numbers is
Where $epsilon is a small number.
Perl 6 - links to (nearly) everything that is Perl 6.
In Section
Seekers of Perl Wisdom
|
|