₹1,23,456.78 is not a formatting detail
Rekhon2 min read
Most apps show ₹123,456.78. Indian digit grouping is ₹1,23,456.78, and reading it should not take three attempts.
Compiled from the repository’s decision records and changelog rather than written as a first-person account. The reasoning is the project’s; the summarising is editorial. The record itself is linked at the end.
Most software groups digits in threes, so a balance reads ₹123,456.78. Indian notation keeps the last three digits together and groups the rest in twos: ₹1,23,456.78. One lakh is 1,00,000, never 100,000. A reader in India takes in the second form at a glance and works through the first one digit at a time.
Rekhon's MoneyFormatter landed on 25 July 2026, with the Money type it formats, and its doc comment records why it does the grouping itself.
Why the standard tools were not used
Java offers two ready answers. java.text.DecimalFormat supports only a single grouping size, so the pattern #,##,##0.00 falls back to groups of three and 1,23,456 comes out as 123,456. The comment says this was verified, not assumed.
NumberFormat.getCurrencyInstance for en-IN gets the grouping right, but it hands the output to the platform's locale data, which differs between JDK versions and Android releases, the spacing around the symbol especially. Every screenshot and unit test would then depend on the machine that ran it.
The rule, written down
So the formatter states the rule instead of delegating it. It turns the paise into an exact digit string, takes the last two digits as paise, keeps the last three rupee digits together and groups everything to their left in twos. A minus sign goes before the ₹, so a refund reads -₹1,23,456.78, and zero is ₹0.00.
private fun groupIndian(digits: String): String {
if (digits.length <= FIRST_GROUP) return digits
val lead = digits.dropLast(FIRST_GROUP)
val pairs = lead.reversed().chunked(LATER_GROUPS) { it.reversed() }.reversed()
return pairs.joinToString(separator = ",") + "," + digits.takeLast(FIRST_GROUP)
}The digit string comes from BigInteger rather than Math.abs, because the absolute value of Long.MIN_VALUE overflows, and no Double is allowed to touch an amount.
Why it counts as correctness
The formatter lives in :core:model beside Money, not in the UI layer. It uses only the Kotlin and JVM standard library, so the engines format amounts for logs and exports with the same function the screens use, and a test can assert on one canonical string that is identical on every JVM and device.
Reading amounts got the same treatment. parse() accepts what a person types, from 45000 to ₹1,23,456.78, and stays on text and BigInteger, because "0.07".toDouble() * 100 is 7.000000000000001. Anything more precise than paise, or outside the range of a Long, returns null instead of a guess.
A parser that guesses is worse than one that declines, because the user cannot see it guessing.
It accepts ASCII digits only. Char.isDigit() also accepts Devanagari digits such as १, which then throw inside BigInteger: a validation that reads as correct and crashes. For an app built for India, that input is plausible rather than exotic.