[Gllug] Sum trouble
Richard Jones
rich at annexia.org
Tue Apr 8 10:52:40 UTC 2003
On Tue, Apr 08, 2003 at 10:59:23AM +0100, Tethys wrote:
>
> Richard Jones writes:
>
> >The problem you'll have with all the methods suggested below is
> >that they'll overflow at 2 or 4 GiB. (I assume you have a fair-
> >sized amount of data being transferred?)
>
> Because mine uses dc to do the addition, it won't overflow.
> I admit it's more clumsy than some of the others, though.
>
> As useful scripting tools go, dc rocks...
What the world needs is a useful 'fold' operation.
Unfortunately 'sum' is used (creates checksums).
'add' is not used, but it's limiting.
'fold' is used (break lines).
I guess we could call it 'foldr' or 'foldl' :-)
... | foldl '+'
Rich.
--
Richard Jones, Red Hat Inc. (London office, UK) http://www.redhat.com/
http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj
PTHRLIB is a library for writing small, efficient and fast servers in C.
HTTP, CGI, DBI, lightweight threads: http://www.annexia.org/freeware/pthrlib/
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list