Front page | perl.beginners |
Postings from April 2002
formatting numbers
Thread Next
From:
pat
Date:
April 28, 2002 21:34
Subject:
formatting numbers
Message ID:
MABBIFOACBDFHBPPMNEBKEAJEMAA.pat@msasa.co.zw
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:-
#!/usr/bin/perl
#Program that needs formatting of numbers
$Tot_time="383.3";
$Grand_total="37492908";
$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
-
formatting numbers
by pat