Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Results depending on evaluation order

by InfiniteSilence (Curate)
on Apr 23, 2014 at 18:47 UTC ( [id://1083414]=note: print w/replies, xml ) Need Help??


in reply to Results depending on evaluation order

There is a difference between what is represented and what is actually being stored,

DB<11> p sprintf("%.8f", $expected); 1.98000000 DB<10> p sprintf("%.8f", $premium); 1.98000000 DB<12> p ($expected == $premium) DB<13>
When you subtract the two the difference is exposed:
DB<16> p ($expected - $premium) -2.22044604925031e-16

But it is very small. Let's lop off the unnecessary information:

DB<13> $pa = 1.98 DB<14> $pb = 1.98 DB<15> p ($pb == $pb) 1 DB<17> p ($pb - $pa) 0 DB<18> DB<22> $exp = sprintf("%.8f", $expected) DB<23> $pre = sprintf("%.8f", $premium) DB<24> p ($pre - $exp) 0

So you see if you set limits on what Perl stores you should get more accurate comparisons.

Celebrate Intellectual Diversity

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (8)
As of 2024-04-23 17:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found