# Numbers, currencies, units, and collation

## Number formatting

Use locale-aware formatters for decimal, percent, scientific, compact, and unit styles. Keep the raw numeric value separate from formatted output.

Do not assume:

- Decimal separator is `.`.
- Group separator is `,`.
- Grouping always uses groups of three.
- Digits are always Latin.
- Percent sign placement is fixed.
- Minus signs and accounting notation are interchangeable.

## Parsing

Formatting APIs do not automatically provide safe round-trip parsing. For critical numeric input:

1. Define accepted locale and numbering systems.
2. Normalize allowed separators and digits deliberately.
3. Reject ambiguous or mixed conventions.
4. Show the parsed value before submission where consequences matter.
5. Revalidate on the server.

## Money

Store:

```text
amount + ISO currency code + precision/rounding policy
```

- Do not store a preformatted money string as canonical data.
- Do not derive currency solely from locale.
- Do not assume all currencies use two fraction digits.
- Separate display rounding from settlement and accounting rules.
- Use currency code when symbols are ambiguous across markets.

## Units

- Store quantity and unit separately.
- Use locale data for display names and placement.
- Apply conversion only with an explicit product rule.
- Keep precision and significant-digit rules aligned with the domain.

## Lists and display names

Use locale-aware list formatting for conjunctions and disjunctions. Use display-name APIs or curated locale data for languages, regions, scripts, currencies, calendars, and date fields instead of hard-coded English labels.

## Collation, search, and grouping

- Use locale-aware collation for user-visible sorting.
- Specify whether case, accents, punctuation, numeric substrings, and variant differences matter.
- Do not use collation order for stable identifiers or cryptographic behavior.
- Keep database and client collation behavior aligned when pagination or filtering crosses system boundaries.
- Test Turkish dotted and dotless I, German variants, Scandinavian ordering, CJK collation, and numeric strings as relevant to supported locales.
