Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: (s)printf and rounding woes

by arthas (Hermit)
on Nov 04, 2003 at 23:38 UTC ( #304575=note: print w/replies, xml ) Need Help??


in reply to (s)printf and rounding woes

Hi!

Problem is that computers represent floating point numbers in binary; this means a decimal number can't exacly be represented in binary form, and the precision in doing this is finite. This affects all languages. As somebody already replied, if precision really matters to you, you need to work with integers, and perform the division as late as you can.

There's a perlfaq entry about this, which might make things clearer to you.

Hope this helps!

Michele.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2019-06-19 05:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (83 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!