printf: zero pad after the decimal a given amount
  Home FAQ Contact Sign in
comp.lang.perl.misc only
 
Advanced search
POPULAR GROUPS

more...

 Up
printf: zero pad after the decimal a given amount         

Group: comp.lang.perl.misc · Group Profile
Author: jidanni
Date: Mar 30, 2008 13:09

Why is there no way to tell printf to zero pad like the right column:
0.1 :0.100
0.05 :0.050
0.03 :0.030
0.025 :0.025
0.02 :0.020
0.015 :0.015
0.0125 :0.0125
0.01 :0.010
0.009 :0.009
0.00625:0.00625
0.005 :0.005
The challenge: Change only the "WHAT?" below to produce the right
column above. Thanks.
use constant S => 100000;
for ( 10000, 5000, 3000, 2500, 2000, 1500, 1250, 1000, 900, 625, 500 ) {
printf "%%-7g:WHAT?\n", $_ / S, $_ / S;
}
12 Comments
diggit! del.icio.us! reddit!