Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Results depending on evaluation order

by fishy (Sexton)
on Apr 23, 2014 at 16:50 UTC ( #1083392=note: print w/ replies, xml ) Need Help??


in reply to Re: Results depending on evaluation order
in thread Results depending on evaluation order

Interesting. Thanks Rolf!

What about eval? Why it got right evaluated?


Comment on Re^2: Results depending on evaluation order
Re^3: Results depending on evaluation order
by moritz (Cardinal) on Apr 23, 2014 at 17:51 UTC

    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 ));
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1083392]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2014-08-01 15:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (27 votes), past polls