Posted by lawpoop on 09/28/41 12:00
Hello all --
I'm trying to format decimal numbers for a report. I would have to
have the number with leading zeros to the tens' place, and trailing
zeros to the thousandths' place.
I'm using sprintf("%02.2f", $num) to get the following results:
0.5 : 0.50
0.55 : 0.55
5.5 : 5.50
55.5 : 55.50
55.55: 55.55
100 : 100.00
It does the trailing zeros correctly, but not the leading zeros. I
would like 5.5 to become 05.50 .
I don't really understand the syntax of the format specifier of
sprintf. Can someone help me out or point me to a good tutorial?
[Back to original message]
|