Cash App Jun 6, 2023

Kotlin Multiplatform Money Formatter

M6 Related OWASP risk: Inadequate Privacy Controls Learn more →

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

Critical Insight

Cash App unified money formatting across all platforms with Kotlin Multiplatform, eliminating inconsistencies while maintaining the precision financial apps require.

The article details their two-phase formatting approach that splits platform-specific and common code in a clever way.

About This Article

Problem

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.

Solution

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.

Impact

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.