[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] How do I turn 17.1 into "017.100" ?



Do you care about numbers that exceed 4 decimals?  They'll get chopped
in a printf....

pbaker@razorbill:~> perl -e "printf('%07.3f',17.1)"
017.100

pbaker@razorbill:~> perl -e "printf('%07.3f',17.12345)"
017.123

-----Original Message-----
From: omaha-pm-bounces@pm.org [mailto:omaha-pm-bounces@pm.org] On Behalf
Of Jay Hannah
Sent: Friday, December 09, 2005 1:52 PM
To: omaha-pm@pm.org
Subject: [Omaha.pm] How do I turn 17.1 into "017.100" ?

Given any number I want a string where (1) the whole string is 7
characters long, (2) there are three digits after the decimal point, and
(3) the number is zero padded in front.  

e.g.: 17.1 becomes "017.100".  

Is there a printf FORMAT for this? Or is this a 4 liner?

Thanks,

j

_______________________________________________
Omaha-pm mailing list
Omaha-pm@pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm