good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: (s)printf and rounding woesby arthas (Hermit) |
on Nov 04, 2003 at 23:38 UTC ( [id://304575]=note: print w/replies, xml ) | Need Help?? |
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.
In Section
Seekers of Perl Wisdom
|
|