[HPADM] Adding up a column of number in a file

From: Buddy Mills (ramill@wm.edu)
Date: Wed Dec 01 2004 - 13:01:43 EST


I need to add up a column of about 1500 number in a file. Each one is a line entry.

Example
0076.34
0003.76
0048.76
and so on

I have used the following two awk scripts.

{ for ( i=1 ; i<=NF ; i=i+1 ) sum = sum + $i}
END { print sum

And

{ total += $1 }
END { print total }

Both want to round off/drop the last numbers. My file should total 12405.31 and both scripts give me 12405.3

Any ideas or better ways to do this?

Thanks

Buddy Mills
The College of William and Mary
757-221-2099 ramill@wm.edu

--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:44 EDT