in reply to Re^2: Adding Leading Zeros
in thread Adding Leading Zeros

Hello tusty,

Please see the FAQ Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)?, which references this article.

...and how do I fix this?

Here’s one way:

19:35 >perl -wE "printf(qq[%012d], 17.40 * 100);" 000000001739 19:35 >perl -wE "printf(qq[%012d], int((17.40 * 100) + 0.5));" 000000001740 19:35 >

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,