SQLite Forum

Decimal128
Login
In theory, it may be easy to compute, for a given operation, but in practice, it gets hard, unless you do a correction after almost every operation, which frankly isn't practical.

For example, what scaled epsilon should you use for the result of:

SELECT SUM(price) as total_sales FROM Sales;

Let us say you have on the order of a million records and an average sales price on the order of $1000.

The round-off error, by my calculation, now possibly exceeds the penny, and you can't really assume independence of the rounding to give you likely canceling, as the penny values in prices are really 'random', but are very often things like .99, so we may well have consistent rounding biases. 

The fundamental issue here is that the database didn't store the data we really wanted, prices are EXACT quantities, but we just stored an approximation. (Which is one of the major reasons DECIMAL formats got a start in business programming, they can keep exact numbers as exact).