SQLite Forum

Decimal128
Login
I'll admit it, looks like I remembered the wrong rounding problem, the error in 0.1 is small enough that the error when you *10 still rounds down to 1.0

But try 0.1 + 0.2 == 0.3
That fails, and that is the sort of failure that pops up all over the place is one of the issues with binary floating-point.

If you think of floating-point number as appoximations to actual numbers you are ok, but we like to think of our data as what we actually entered. If we enter the name as Robert, we don't want Roberta, if we say we have 54321 widgets in inventory, we don't want the value 54320 back. When we enter a number with a decimal, we mean precisely that value (yes, we may know the value is a measurement with a tolerance, but the number is the number). 

For many fields, the approximation works, but in others the errors are unacceptable. If I add up thousands of sales with decimals, I expect to get the EXACT result, but I need to carefully manage my computations to get it right to the penny. This is where using Decimal floating-point has a big advantage, now the computer is dealing with the exact same numbers the people are, not just some approximations.