in reply to eq vs ==

Thanks everyone for the quick and complete replies. The binary fractions problem had not even occurred to me (I come from a Java background), but at least now I understand the irregularity of the errors and why I have not seen it before.

It makes sense that different users have differing opinions on what "acceptable precision" is, hence why there isn't a standard equality operator.

Thanks again

Replies are listed 'Best First'.
Re^2: eq vs ==
by Fox (Pilgrim) on Nov 10, 2009 at 18:07 UTC
    please note that this is not a perl problem, all languages suffer from these same problems. see Java double traps as an example.
      This is a language implementation problem. Some languages are lucky enough in their specifications to be able to handle infinitely long numbers and use ratios rather than floats.
        To use ratios alternatively to floats is a good idea, but not every number is a rational number, and "handling infinitely long numbers" would imply infinite memory!

        Shouldn't be too difficult to implement this behavior via overload in Perl just like BigInt, I'm even sure it has already been done on CPAN.

        Cheers Rolf

Re^2: eq vs ==
by LanX (Saint) on Nov 10, 2009 at 18:56 UTC
    The binary fractions problem had not even occurred to me (I come from a Java background)

    ROFL!

    ... sorry no more comment, I'm in a hurry, I have to run and sell SUN stock options! 8)

      I'd forgotten about the need to flame on forums. Thanks for reminding me, and I'll be sure to make an effort to cut someone else down when I get the chance.
        Yeah, and I forgot that at this forum critic should always be expressed as anonymous coward monk...

        Cheers Rolf

        PS: Oops, I did it again ... gosh ...posting with well known identity! Silly me ... 8)