Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: bignum frustration

by SuicideJunkie (Priest)
on Aug 15, 2012 at 21:39 UTC ( #987637=note: print w/ replies, xml ) Need Help??


in reply to bignum frustration

use bignum; $foo = 12345.6789; $bar = $foo->copy()->bfround(0)->bfround(-5); $baz = $foo - $bar; print "what's wrong here? $foo - $bar = $baz\n"; $byhand = 12345.6789 - 12345; print "expected $byhand\n";
Gives:
what's wrong here? 12345.6789 - 12346.00000 = -0.32110 expected 0.6789
Seems to me that the precision is propagated to the result value, and -0.32 rounds up to zero in your original example.


Comment on Re: bignum frustration
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2014-09-02 03:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (18 votes), past polls