summaryrefslogtreecommitdiff
path: root/doc/rounding-errors.doc
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2014-02-15 23:25:11 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2014-02-15 23:25:11 +0100
commitff62eabe7e4045721c8a22fb0d0ab75dc85cdb06 (patch)
tree8695020bdfe82336621f63388e7e5d013e3910ef /doc/rounding-errors.doc
parent3522873f95597519d8bccc6e4f3e0c5c6ae7d119 (diff)
parent19bbac8e6415edd96035c4a5cd052f3701f9657a (diff)
merge
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
+
+*/