kmp-money
Installation
SKILL.md
Money in KMP (commonMain)
Cardinal rule
- Never use
Double/Floatfor money. Binary floating point cannot represent0.10; sums drift and rounding is undefined. This applies to storage, arithmetic, serialization, and equality. java.math.BigDecimalis JVM-only — unavailable incommonMain. That is why KMP needs either integer minor units or a multiplatform bignum.- Pick one representation and keep it at the boundary:
- Minor units (
Longcents) — simplest, exact, fast. Good default for a fintech ledger where every currency has a fixed exponent. Watch for overflow on very large aggregates and awkward sub-cent intermediate math (interest, FX). - Arbitrary-precision decimal — use
com.ionspin.kotlin:bignumwhen you need sub-minor-unit precision, FX rates, or percentages. Pure-KotlinBigDecimal, works on Android + iOS + JS/Wasm.
- Minor units (