Re: Formatting the decimals

2004-01-29 Thread Adam
Owen is dead on, but I think we can do that with less code. Try something like: printf ("%0.2f\n", $_) while (<>); Regards, Adam On Jan 29, 2004, at 5:25 AM, Owen Cook wrote: On Thu, 29 Jan 2004, Mallik wrote: How do I format the decimals, i.e, if there is no decimal part, then add .00, if th

Re: Formatting the decimals

2004-01-29 Thread John W. Krahn
Mallik wrote: > > Dear Friends, Hello, > How do I format the decimals, i.e, if there is no > decimal part, then add .00, if there is one decimal, > then add '0'. > > For eg., how to convert 123 to 123.00 > and 123.5 to 123.50. printf "%.2f\n", $_ for 123, 123.5; John -- use Perl; program fu

Re: Formatting the decimals

2004-01-29 Thread Owen Cook
On Thu, 29 Jan 2004, Mallik wrote: > How do I format the decimals, i.e, if there is no > decimal part, then add .00, if there is one decimal, > then add '0'. > > For eg., how to convert 123 to 123.00 > and 123.5 to 123.50. sprintf Try this - #!