Kotlin Multiplatform Money Formatter
Article Summary
Patrick Tyska and Terry Yiu from Cash App reveal how the same $1,000 needs to display four different ways across their app. Their solution? Kotlin Multiplatform to consolidate 10 separate money formatters into one.
Cash App engineers built a unified money formatter using Kotlin Multiplatform to replace 10 platform-specific implementations. The challenge: displaying money accurately across currencies, locales, and contexts (from payment pads to Bitcoin denominations) while maintaining precision customers trust.
Key Takeaways
- Consolidated 10 existing formatters into single Kotlin Multiplatform implementation
- Leverages native platform code (NSNumberFormatter, ICU) for localized number formatting
- Uses BigDecimal and BigInt to avoid floating point rounding errors
- Already live in Cash App Android with thorough migration testing
- Supports ISO currencies plus Bitcoin with extensibility for future additions
Cash App unified money formatting across all platforms with Kotlin Multiplatform, eliminating inconsistencies while maintaining the precision financial apps require.
About This Article
Cash App needed to handle money across different currencies accurately. 32-bit integers weren't large enough for some denominations, and floating-point numbers could introduce rounding errors that would make customers question the financial accuracy.
Patrick Tyska and Terry Yiu used Kotlin Multiplatform to tap into platform-specific numeric types. They used BigDecimal for Java and BigInt for JavaScript, which gave them the precision they needed without building everything from scratch for each ecosystem.
The formatter now lets new currencies be added through simple library entries that work on all platforms automatically. Teams no longer need to maintain separate implementations or keep multiple money-formatting experts on staff.