aboutsummaryrefslogtreecommitdiff
path: root/doc/rounding-errors.doc
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-03-01 21:26:25 +0100
committerSebastian Geerken <devnull@localhost>2014-03-01 21:26:25 +0100
commit975ba73389d2de0cd2bb50183bd988eab6ba0e06 (patch)
tree67947a7e22dd049685dc034223c212e2ae14c902 /doc/rounding-errors.doc
parent6369c18d186d52f0f3f5082ff6c9fdcf5c9285d1 (diff)
parent8818cda9ca4e4c19c4c5fcee68460d5ba0cd5ba2 (diff)
Merge with main repo.
Diffstat (limited to 'doc/rounding-errors.doc')
-rw-r--r--doc/rounding-errors.doc15
1 files changed, 13 insertions, 2 deletions
diff --git a/doc/rounding-errors.doc b/doc/rounding-errors.doc
index 133a1fe5..a442033e 100644
--- a/doc/rounding-errors.doc
+++ b/doc/rounding-errors.doc
@@ -19,6 +19,17 @@ avoided by transforming the formula into
Of corse, when all \f$y_i\f$ are calculated in a sequence,
\f$\sum_{j=0}^{j=i} x_j\f$ and \f$\sum_{j=0}^{j=i-1} y_j\f$ can be
-accumulated in the same loop.
+accumulated in the same loop. Regard this as sample:
-*/ \ No newline at end of file
+\code
+int n, x[n], a, b; // Should all be initialized.
+int y[n], cumX = 0, cumY = 0;
+
+for (int i = 0; i < n; i++) {
+ cumX += x[i]
+ y[i] = (cumX * a) / b - cumY;
+ cumY += y[i];
+}
+\endcode
+
+*/