in reply to Re^3: problem with variables
in thread problem with variables

Actually, now that brain is in gear, I think you *always* want to use eq rather than == for comparing floats. If you use
sprintf( "%.3f", $num1 ) == sprintf( "%.3f", $num2 )
that just puts you right back to where you started: comparing floats with ==.

Replies are listed 'Best First'.
Re^5: problem with variables
by Roy Johnson (Monsignor) on Oct 19, 2005 at 19:10 UTC
    Yes, but if the strings are eq, the floats that come from those strings will be ==. It's a deterministic thing. That said, it makes more sense to compare them with eq, since the output of sprintf is a string. Why force the conversion back?

    Caution: Contents may have been coded under pressure.