A Century of Missing Interest

Medium

· Backend

Incident

SEV-1

BUG-DIV0INT

Priority: Critical (regulatory) · reported by core banking

Time to fix: 20 min

Failing checks on the shipped build

  • one year of five percent

    expected 10500 but got 10000

  • two years compound

    expected 11025 but got 10000

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Inspired by

Core banking

Inspired by the interest-calculation bugs that have triggered real banking remediations: integer division runs before multiplication, rate / 100 becomes zero, and a decade of compounding earns exactly nothing.

Interest.java compounds yearly, in integer cents.

Code map

class Interest {
    static long compound(long principalCents, int ratePercent, int years) {
        long value = principalCents;
        for (int i = 0; i < years; i++) {
            value = value + value * (ratePercent / 100);
        }
        return value;
    }
}

Sign in to edit the file, run the tests and submit a fix

A free account — no card, no trial clock. You come straight back here.

A Century of Missing Interest — Java Bug Hunt

Inspired by the interest-calculation bugs that have triggered real banking remediations: integer division runs before multiplication, rate / 100 becomes…

  • Language: Java
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Integer Division, Finance
  • Modelled on: Core banking
  • Visible tests: one year of five percent; two years compound; zero years returns the principal
  • Reward: 50 XP for a complete fix

Incident

  • Severity: SEV-1 (priority: Critical (regulatory))
  • Ticket: BUG-DIV0INT
  • Reported by: core banking
  • Time to fix: 20 minutes, the target for a medium incident

Failing checks on the shipped build

  • one year of five percent — expected 10500 but got 10000
  • two years compound — expected 11025 but got 10000

How to work this incident

  1. Read the report: write down the expected behaviour and the actual one in a sentence each.
  2. Reproduce it: run the visible tests and find the failing check that matches the report.
  3. Read the logs and the failing checks for the first value that is wrong — the earliest wrong value is nearer the cause than the loudest error.
  4. Follow the request through the handler, the validation and the service it calls; find the first step whose output disagrees with the report.
  5. Fix the cause rather than the symptom, run the visible tests again, and submit against the hidden ones — then write the root cause down.

Briefing

Inspired by the interest-calculation bugs that have triggered real banking remediations: integer division runs before multiplication, rate / 100 becomes zero, and a decade of compounding earns exactly nothing.

Interest.java compounds yearly, in integer cents.

Bug report

BUG-DIV0INT · Priority: Critical (regulatory) · Reported by: core banking

compound(principalCents, ratePercent, years):

  • one compounding per year: value = value * (100 + rate) / 100 (floor)
  • 10000 cents at 5% for 1 year -> 10500; 2 years -> 11025

Observed: every account earned 0 interest — 5 / 100 is 0 in integer math.

Logs

[interest] 10000 @ 5% x 10y -> 10000

The code as shipped

Interest.java (editable)

class Interest {
    static long compound(long principalCents, int ratePercent, int years) {
        long value = principalCents;
        for (int i = 0; i < years; i++) {
            value = value + value * (ratePercent / 100);
        }
        return value;
    }
}

Open the hunt to start the incident clock, edit the files, run the visible tests and submit against the hidden ones, then write the root cause down. More Java bug hunts.