Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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 meditating upon the Monastery: (9)
As of 2015-07-08 05:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls