Tablora

Tablora · Library

Check 0.10 plus 0.20 as exact decimals

Check that 0.10 plus 0.20 equals exactly 0.30 with decimal arithmetic, so a stated total is compared without floating-point display artifacts.

Why 0.1 plus 0.2 can look wrong

Many programs store numbers in binary floating point, where 0.1 and 0.2 have no exact representation. Add them and the stored result is a hair above 0.3; depending on formatting, you may see 0.30000000000000004 or a comparison that says the values are not equal. In a reconciliation, that kind of artifact looks like a discrepancy that is not really there.

The decimal totals checker avoids it. It reads each value as a decimal string, scales all values to the same number of decimal places and adds them as whole numbers, so 0.10 and 0.20 add to exactly 0.30.

Entering the lines

Result for 0.10 and 0.20

With the values 0.10 and 0.20 and an Expected total of 0.30, the Calculated total is 0.30, the Difference is 0.00 and Totals match shows Yes. The result keeps two decimal places because that is the largest number of places among the inputs and the expected total.

Difference is always Calculated total minus Expected total, so a negative difference means the entered lines fall short of the stated figure.

Preparing values from a real table

Amounts copied from a statement rarely arrive in canonical form. Run the column through the numeric normalizer first, choosing the decimal and grouping separators the document uses, then copy the converted values into the checker. A value the normalizer held for review is not ready for the sum; resolve it before you trust the total.

The checker does exact arithmetic on what you enter and nothing more. It does not convert currencies, apply tax or rounding rules, or tell you whether every record was entered.

Inputs the checker refuses

Original synthetic example

Values
0.10 0.20
Expected total
0.30
Calculated total
0.30
Calculated minus expected
0.00

Tools