We wrote 159 automated tests for arithmetic. Here is why.

"It is just arithmetic" is the most expensive sentence in this codebase.

Every calculator on EMICalcs is covered by automated tests that run on every build. There are 159 of them, and if any figure drifts from its expected value the build fails and nothing ships. People occasionally ask why compound interest needs a test suite. This post is the answer, and it is a single number.

The cliff

Take a salaried person under the new regime for FY 2026-27. Gross pay ₹12,75,000. After the ₹75,000 standard deduction, taxable income is exactly ₹12,00,000.

Their tax is ₹0. The section 87A rebate wipes it out entirely.

Now give them a ₹100 raise. Gross ₹12,75,100, taxable ₹12,00,100 — one hundred rupees over the rebate ceiling.

Their tax is ₹104.

Not ₹62,416, which is what the slabs alone produce on ₹12,00,100 once you add 4% cess. ₹104. The difference is marginal relief: when crossing the rebate threshold would cost you more in tax than the raise itself, the tax is capped at the excess income. One hundred rupees over, so one hundred rupees of tax — then 4% health and education cess on top, giving ₹104.

Why that is a test and not a footnote

A calculator that implements the slabs correctly, applies the rebate correctly, and simply does not know marginal relief exists will tell that person they owe ₹62,416.

It will not crash. It will not look wrong. It will produce a confident, well-formatted, plausible number that is out by a factor of six hundred — and it will do it to precisely the people who can least afford the surprise, those sitting just above a threshold.

That is the shape of every serious bug in this domain. Not 2 + 2 = 5. A rule you did not know existed, or one that changed while you were not looking.

The rules move every year

Slabs shift. The rebate ceiling moves. Cess rates change. The standard deduction differs between regimes and moves independently in each. Surcharge thresholds have their own marginal relief, with different arithmetic again.

A test suite is not there to prove the formula was right when it was written. It is there so that when a Budget changes one number, everything that quietly depended on it fails loudly instead of shipping.

Some of these tests exist because something did go wrong. The rebate cliff above is one of them.

What it looks like in practice

Every figure in this post came out of the income tax calculator, not a spreadsheet. A few more from the same engine, all FY 2026-27, salaried, new regime:

  • ₹12,00,000 gross → ₹0 tax (old regime: ₹1,17,000)
  • ₹15,00,000 gross → ₹97,500 (old regime: ₹2,10,600)
  • ₹24,00,000 gross → ₹2,92,500 (old regime: ₹4,91,400)

The old-regime column assumes ₹1,50,000 of deductions, which is the assumption most comparisons make silently. It is stated on the page rather than buried, because a comparison that hides its assumptions is not a comparison.

The calculator is free, needs no signup, and shows the slab-by-slab working rather than a single bold figure. If you find a number you disagree with, the working is right there to argue with — which is rather the point.

Comments

Popular posts from this blog

Three Indian EMI calculators, three different answers

Your calculator should work with JavaScript switched off