Money and separators test values
Amounts written the way people and spreadsheets write them, and where precision ends. 12 values, each with what it breaks and what a correct application does instead.
Type them one at a time with AltShiftN
in the palette, or take them all into a script with nkb emit currency-separators.
Rounding trap 2,675
currency-separators/rounding-2675
2,675
2,675
- 5 graphemes
- 5 code points
- 5 bytes
- 5 UTF-16 units
- What it breaks
- Rounded to two places this value goes down where a human expects it to go up, because the binary representation is slightly below the decimal one.
- What a correct application does
- Rounded by a rule stated in the specification, applied identically in the interface and in storage.
Rounding trap 1,005
currency-separators/rounding-1005
1,005
1,005
- 5 graphemes
- 5 code points
- 5 bytes
- 5 UTF-16 units
- What it breaks
- The same failure at a different magnitude; one of the two catches almost every naive rounding implementation.
- What a correct application does
- Same as above.
Comma as the decimal separator
currency-separators/comma-decimal-money
1234,56
1234,56
- 7 graphemes
- 7 code points
- 7 bytes
- 7 UTF-16 units
- What it breaks
- The decimal separator used locally; a parser expecting a dot reads it as a thousands separator and multiplies the amount by a hundred.
- What a correct application does
- Accepted in locales that use it, with the expected format shown.
Non-breaking spaces between thousands
currency-separators/nbsp-thousands
1000000,00
1\u00A0000\u00A0000,00
- 2 spaces that are not an ordinary space
- 12 graphemes
- 12 code points
- 14 bytes
- 12 UTF-16 units
- What it breaks
- Amounts copied from a report carry non-breaking spaces as group separators, which no numeric parser accepts.
- What a correct application does
- Separators stripped before parsing, including the invisible ones.
Spaces between thousands
currency-separators/space-thousands
1000000,00
1 000 000,00
- 12 graphemes
- 12 code points
- 12 bytes
- 12 UTF-16 units
- What it breaks
- The same with ordinary spaces - the form produced by most local formatting.
- What a correct application does
- Accepted and normalised.
Negative amount in brackets
currency-separators/negative-parens
(1234,56)
(1234,56)
- 9 graphemes
- 9 code points
- 9 bytes
- 9 UTF-16 units
- What it breaks
- Accounting notation for negative amounts; read as text it becomes a positive number in brackets.
- What a correct application does
- Interpreted as negative, or rejected with the expected form shown.
Three decimal places
currency-separators/three-decimals
1234,567
1234,567
- 8 graphemes
- 8 code points
- 8 bytes
- 8 UTF-16 units
- What it breaks
- More decimal places than the currency has; silently rounding here changes an invoice total.
- What a correct application does
- Rejected, or rounded with the rounding shown before saving.
Negative zero
currency-separators/negative-zero
-0,00
-0,00
- 5 graphemes
- 5 code points
- 5 bytes
- 5 UTF-16 units
- What it breaks
- A negative zero displays as a negative amount and compares equal to zero; reports show a minus sign on nothing.
- What a correct application does
- Normalised to zero on save.
Zero amount
currency-separators/zero-amount
0,00
0,00
- 4 graphemes
- 4 code points
- 4 bytes
- 4 UTF-16 units
- What it breaks
- Zero is a legitimate amount and is frequently confused with an empty field.
- What a correct application does
- Stored and displayed as zero, distinct from empty.
Amount with the currency symbol
currency-separators/symbol-appended
1234,56zł
1234,56 zł
- 10 graphemes
- 10 code points
- 11 bytes
- 10 UTF-16 units
- What it breaks
- The amount as it appears in a document, with the currency symbol; a numeric field rejects it whole.
- What a correct application does
- The symbol stripped on input, or the expected form shown.
Apostrophe between thousands
currency-separators/apostrophe-thousands
1'234.56
1'234.56
- 8 graphemes
- 8 code points
- 8 bytes
- 8 UTF-16 units
- What it breaks
- The group separator used in some locales; unfamiliar and perfectly legitimate.
- What a correct application does
- Accepted where that locale is supported, or rejected with the expected form.
Amount wider than the money type
currency-separators/huge-amount
999999999999,99
999999999999,99
- 15 graphemes
- 15 code points
- 15 bytes
- 15 UTF-16 units
- What it breaks
- An amount wider than the type used for money; overflow here produces a negative total.
- What a correct application does
- Rejected with a stated limit, before it reaches any total.