develooper Front page | perl.beginners | Postings from April 2002

formatting numbers

Thread Next
April 28, 2002 21:34
formatting numbers
Message ID:
I have been through man printf, info printf and perldoc -f print and still
can't find how to format numbers.
In the program below I would like to print the numbers as below:
	383.3    as 383.30
	37492908 as 37 492 908
	35.7560234069824 as 35.76
	1631.11929000261 as 1 631
Please can someone put me right. Many thanks for introducing me to the split
command/function it sure is a winner.
My simple program which prints unformatted is below
Many thanks Pat.
Program follows:-
#Program that needs formatting of numbers
$Tot_megsG = $Grand_total / 1024 /1024;
print "Grand Total   = $Grand_total\t";
print "$Tot_megsG  megabytes\n\n";
print "Total time    = $Tot_time in minutes \n\n";
$seconds = ($Tot_time * 60);
$avercps = ($Grand_total / $seconds);
print "Average CPS   = $avercps \n\n";
print "Program has ended....\n\n";

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About