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

Sean Baker pbaker at omnihotels.com
Fri Dec 9 12:03:37 PST 2005


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

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

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

-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Jay Hannah
Sent: Friday, December 09, 2005 1:52 PM
To: omaha-pm at 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 at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm



More information about the Omaha-pm mailing list