Re: [Rd] prod(0, 1:1000) ; 0 * Inf etc

From: Berwin A Turlach <>
Date: Tue, 22 Apr 2008 11:10:02 +0800

G'day Martin,

On Mon, 21 Apr 2008 18:40:43 +0200
Martin Maechler <> wrote:

> I think most of us would expect prod(0:1000) to return 0, and ...
> ... it does.
> However, many of us also expect
> prod(x1, x2) to be equivalent to
> prod(c(x1,x2))
> the same as we can expect that for min(), max(), sum() and such
> members of the "Summary" group.

Many may also expect that prod(x) and prod(rev(x)) are equivalent. Unfortunately, this does not hold in finite precision arithmetic:

> prod(0:1000)
[1] 0
> prod(1000:0)

[1] NA
> prod(rev(0:1000))

[1] NA

It might be better to educate useRs on finite precision arithmetic than trying to catch such situations. Note, I am saying "better", not "easier". :-)


        Berwin mailing list Received on Tue 22 Apr 2008 - 03:12:26 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Apr 2008 - 08:31:16 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive