Skip to content

Implement DefaultFormatter.DigitSeparator #274

@gavv

Description

@gavv

Implement new option DigitSeparator with four values:

  • DigitSeparatorUnderscore (default)
  • DigitSeparatorComma
  • DigitSeparatorApostrophe
  • DigitSeparatorNone

When DigitSeparatorUnderscore is used, integers and floats should be formatted with thousand separators like this:

1_000_000
3.141_592_653

DigitSeparatorComma and DigitSeparatorApostrophe are similar, but use , and ' as separator, instead of _. DigitSeparatorNone corresponds to current behavior when no separator is used.

All numbers are formatted using DefaultFormatter.formatValue, so DigitSeparator should be handled there. It already has branches for float32 and float64; now we'll need to add branch for integers (we can use refIsNum function).

For an example of similar option and its handling, see DefaultFormatter.FloatFormat.

New option should have documentation. Formatter tests should be updated.

https://en.wikipedia.org/wiki/Decimal_separator
https://en.wikipedia.org/wiki/Integer_literal

Metadata

Metadata

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions