# total -p and zeroes

Dear list,

I'm trying to use total -p to multiply two rows of data like this:

\$ echo -e "0 1 2 3\n2 3 4 5"
0 1 2 3
2 3 4 5

\$ echo -e "0 1 2 3\n2 3 4 5" |total -p
2 3 8 15

I would expect 0 * 2 = 0 in the first column. Does the -p option not like zeroes? A straight-forward sum gives the expected result:

\$ echo -e "0 1 2 3\n2 3 4 5" |total
2 4 6 8

Regards

Axel

Hi Axel,

This is really a bug. Total computes products by converting to a log domain, which of course doesn't work for zero. I can fix this problem, and will do so in the next release.

Cheers for pointing it out.
-Greg

P.S. The reason for converting to log is that it allows geometric means to be computed for almost any set of numbers, which would overflow a straight product.

ยทยทยท

From: Axel Jacobs <jacobs.axel@gmail.com>
Date: January 29, 2010 8:51:49 AM PST

Dear list,

I'm trying to use total -p to multiply two rows of data like this:

\$ echo -e "0 1 2 3\n2 3 4 5"
0 1 2 3
2 3 4 5

\$ echo -e "0 1 2 3\n2 3 4 5" |total -p
2 3 8 15

I would expect 0 * 2 = 0 in the first column. Does the -p option not like zeroes? A straight-forward sum gives the expected result:

\$ echo -e "0 1 2 3\n2 3 4 5" |total
2 4 6 8

Regards

Axel