John Hennessy wrote: > Hi, how is it possible to prefix a leading zero to the $Count result > below when this value is less than 100.0000 ? > > > while ($count < 110.000) { > $count += 10; > $Count = sprintf "%03.4f", $count; > print "Count is now $Count\n"; > } > > I am using %03.4f to provide output that looks like 100.0000 > I would like number less than 100.0000 to look like 099.0000 > I would like to keep the 3 digits prior to the decimal point either with > or without the leading zero as required. > > Any suggestions welcomed.
For floating point formats the number on the left of the period is the total length of the whole floating point number and 099.0000 is eight characters total so you need: $Count = sprintf "%08.4f", $count; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>