fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
19.84k stars 2.42k forks source link

Add support for grouping numbers and '_', ',' separators #3954

Closed amal-khailtash closed 1 month ago

amal-khailtash commented 1 month ago

C++ 14 supports optional digit separators like 1'000'000, 0b1010'1010, or 0xFF'FF'FF

Underscores are also acceptable in literals as described in PEP 498 and PEP-515 using "{number:,}", also for larger numbers a comma separated thousand separator is accepted as in "{number:,}".

It would be great if grouping numbers with separators ("_", "'", ",") are supported. Python groups decimal numbers in 3 digits (thousands), binary, octal and hex numbers are grouped in 4 digits (4 bits, 12 bits, or 32 bits respectively).

NOTE: Python does not allow grouping by a single quote though! "'"

More references here:

vitaut commented 1 month ago

Same as #3840.