SQLite Forum

We are adding a sum of a million numbers of magnitude 1000, thus the sum will be magnitude 10^9, which has an epsilon of 1.2x10^-7, we are adding a million of these, so our error is 10^6 * 1.2*10^7 = 0.12 and thus we have no certainty of being right to the penny.

The issue is that even if individual epsilons are small, unless we have an opportunity in the calculation to perform a rounding to our power of ten, they WILL accumulate.

Add up a hundred 1e-4 epsilons, and you get a possible 1e-2 error. That is basic math,

Or, are you proposing that we somehow redefine our basic math primates to include periodic rounding to a defined number of decimal places?

Note, the math won't fail all the time, and maybe not even most of the time, which is part of the problem, errors like this take effort to root out and takes detailed study to locate, and have the habit of being noticed at the worst time.

As an example, let all 1 million records have a value of 999.95 and sum them. When I do this in python, I get a sum of 999950000.0175645, which when rounded to the penny is now off 2 cents, and unless SQLite3 does special summing rules to minimize accumulated summing errors, it should get about the same.