Currency Code Tools
Currency code tooling: ISO 4217 three-letter codes, symbols and per-currency minor units, why money arithmetic uses integers rather than floats, rounding and floating-point pitfalls in conversion, and the symbol-versus-code localisation trade-off.
Currency codes look like a few letters but carry precision, rounding and localisation details that matter.
Approach Comparison
| Aspect | Floating point | Integer in minor units |
|---|---|---|
| Precision | Binary cannot represent decimals exactly | Exact |
| Accumulation | Errors accumulate | None |
| Representing 1.23 | 1.23, unstable | 123 |
| Rounding | Implicit and uncontrolled | Explicit and controlled |
| Database column | DECIMAL or FLOAT | BIGINT or INT |
| JSON transport | May show precision artefacts | No such issue |
| At display time | Print directly | Convert per currency minor units |
| Applies to | Scientific computing, graphics | Accounting, amounts, billing |
Edge Cases
- ISO 4217 defines minor units per currency: CNY, JPY and KRW use 0, USD and EUR use 2, and several Middle Eastern currencies use 3.
- Converting between currencies is not one multiplication by a rate plus one by 100; minor-unit differences must be handled separately.
- Floats in JSON can show precision artefacts in some languages, so amounts are better transported as strings or integers.
- The rounding direction (up, down, half-up) must be specified explicitly, since defaults differ across languages.
Common Pitfalls
- Multiplying and dividing by 100 for every currency, inflating JPY amounts a hundredfold.
- Accumulating amounts in floating point and ending a batch off by a few cents.
- Storing money in a FLOAT column, where accumulated error surfaces during reconciliation.
- Transporting amounts as JSON floats, where client and server round differently and totals diverge.
Related Tools
- Text StatisticsCount characters, words, lines, bytes and estimate reading time with sentence analysis to gauge content length and overall readability at a single glance.
- JSON FormatterBeautify, minify and validate JSON data with syntax error detection. Catch malformed brackets and commas before they break your API integration or build.
- String PluralizerConvert English nouns between singular and plural forms, including irregular nouns, for dynamic labels and grammatically correct UI labels and output.