Back to blog
Engineering May 21, 2026 7 min read

Why Floating-Point Math Lies to You — and How BigNumber Arithmetic Saves the Day

JavaScript's default Number type silently loses precision at 16 digits. Here's why that matters for finance, science, and even everyday calculations.

The classic gotcha: 0.1 + 0.2

Open any JavaScript console and type 0.1 + 0.2. The answer is 0.30000000000000004 — not 0.3. This isn't a bug. It's how floating-point arithmetic works on every modern computer, in every language.

The reason: computers store numbers in binary, and 0.1 has no exact binary representation. Just like 1/3 can't be written exactly in decimal (it's 0.333…), 0.1 can't be written exactly in binary (it's 0.00011001100… repeating).

Why it matters

For most calculations, the tiny error doesn't matter. 0.30000000000000004 displays as 0.3 just fine. But for finance — calculating interest on a million-dollar loan, multiplying by a daily rate 365 times — those tiny errors accumulate into real money.

A friend of mine once debugged a billing system that was off by $0.07 per invoice because of this exact issue, multiplied across 100,000 invoices per month. The result was a $7,000 monthly discrepancy that nobody noticed for six months.

The fix: BigNumber arithmetic

Libraries like mathjs, decimal.js, and bignumber.js solve the problem by storing numbers as strings of decimal digits and doing the math digit-by-digit. They're slower than native floating-point, but they're exact.

Home of Calculators uses mathjs's BigNumber mode configured to 64 digits of precision for general calculations and 128 digits for financial ones. That's vastly more than any real-world calculation needs — 128 decimal digits could represent the number of atoms in the universe many times over — but it ensures that no rounding error ever creeps into a result.

What this means for you

When our EMI calculator says your monthly payment is $836.88, it really is exactly that — not $836.8800000000001. When our BMI calculator says you're 24.7, it's not a fuzzy approximation; it's the true value to 14 significant figures.

For a calculator you can trust, BigNumber precision is non-negotiable. The performance cost (a few microseconds per operation) is invisible to the user, and the correctness benefit is permanent.

Ready to build your own calculator?

The visual builder is free, no signup, and takes about 5 minutes.

Open the builder