in reply to Results depending on evaluation order

left to right evaluation:

 10 - 10 + 14.4 = (10 - 10) + 14.4 = 0 + 14.4 = 14.4

I already explained that the mantissa needs to be shifted to loose precision.

Cheers Rolf

( addicted to the Perl Programming Language)

Replies are listed 'Best First'.
Re^2: Results depending on evaluation order
by fishy (Friar) on Apr 23, 2014 at 16:50 UTC
    Interesting. Thanks Rolf!

    What about eval? Why it got right evaluated?

      eval expects a string, so the number is converted to a string, and the stringification rounds a tiny bit, so it accidentally produces the right result.

        You can prepend a q before the ( to make eval work correctly, i.e. report the difference.
        $premium = eval q($number * ( 1 + 10/100 ));
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ