Permalink
Browse files

add comment on accuracy

git-svn-id: https://svn.r-project.org/R/trunk@62376 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information...
1 parent 7ff33d3 commit 90f4b34015e5a0179748f53e43dd2aed45ef43e0 ripley committed Mar 23, 2013
Showing with 8 additions and 1 deletion.
  1. +7 −1 src/library/base/man/sum.Rd
  2. +1 −0 src/main/summary.c
@@ -1,6 +1,6 @@
% File src/library/base/man/sum.Rd
% Part of the R package, http://www.R-project.org
-% Copyright 1995-2011 R Core Team
+% Copyright 1995-2013 R Core Team
% Distributed under GPL 2 or later
\name{sum}
@@ -39,6 +39,12 @@ sum(\dots, na.rm = FALSE)
Logical true values are regarded as one, false values as zero.
For historical reasons, \code{NULL} is accepted and treated as if it
were \code{integer(0)}.
+
+ Loss of accuracy can occur when summing values of different signs:
+ this can even occur for sufficiently long integer inputs if the
+ partial sums would cause integer overflow. Where possible
+ extended-precision accumulators are used, but this is
+ platform-dependent.
}
\section{S4 methods}{
This is part of the S4 \code{\link[=S4groupGeneric]{Summary}}
View
@@ -43,6 +43,7 @@
#endif
+/* FIXME: use 64-bit integer accumulator? */
static Rboolean isum(int *x, R_xlen_t n, int *value, Rboolean narm, SEXP call)
{
double s = 0.0;

0 comments on commit 90f4b34

Please sign in to comment.