http://qs1969.pair.com?node_id=304575


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.