in reply to Re: Why is this comparison failing?
in thread Why is this comparison failing?

Dave- Thanks. I should have known better. But I was misled by what I assumed was Perl's rules for how variables were used to build double-quoted strings. I would have thought that floating point numbers that are not integers would show enough decimal places to indicate such. That's how I was misled into thinking that these cases were identical. I realize that I actually don't know how numbers are evaluated for double-quoted strings. Do you have a good reference? Regards, John

Replies are listed 'Best First'.
Re^3: Why is this comparison failing?
by mr_ron (Deacon) on Oct 09, 2015 at 01:18 UTC
    It's not really about string representation or integers. It may be more about the limits of Perl 5 and most programming languages in dealing with fractions and floating point. For example:
    perl -Mstrict -w -e 'if (0.3 == 0.1 * 3) { print "equals\n" } else { p +rint "* difference * ", abs(0.3 - 0.1 * 3), "\n" }' * difference * 5.55111512312578e-17
    Ron
Re^3: Why is this comparison failing?
by dave_the_m (Monsignor) on Oct 09, 2015 at 08:45 UTC
    I'm not sure it's documented anywhere. The number of significant digits it uses varies by platform, but typically it stringifies a float to 15 significant digits, with trailing 0's excised.

    Dave.