liveBook · Manning

Digit separator

As explained in Learn C++ by Example

A digit separator is a source-code character that visually groups digits within a numeric literal without changing its value.

A digit separator groups digits inside a numeric literal so large values are easier to read without changing their value. In C++, use a single quote between digit groups: 1'000'000'000. A comma is an operator, so 1,000,000,000 does not provide the same separator syntax. section 4.2.3

Readable nanoseconds

Instead of counting zeros in 1000000000, write int readable_nano = 1'000'000'000;. The value stays the same, while the groups make its scale easier to check. section 4.2.3

int readable_nano = 1'000'000'000;

View the complete C++ declaration using a digit separator. section 4.2.3

How Learn C++ by Example covers it

How deep it goes
Explains the separator’s practical syntax and comma conflict without detailing lexical rules.
Examples
Uses 1'000'000'000 and contrasts it with comma-grouped 1,000,000,000.
What you can do after
Apply it via C++ single-quoted separators to make large numeric literals easier to inspect.
How it connects
Connects numeric literals with chrono durations and user-defined literal suffixes.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn C++ by Example. The section links point to the parts of the book it draws on.