Digit Separator

suggest change

Numeric literals of more than a few digits are hard to read.

C++14 define Simple Quotation Mark \' as a digit separator, in numbers and user-defined literals. This can make it easier for human readers to parse large numbers.

long long decn = 1'000'000'000ll;
long long hexn = 0xFFFF'FFFFll; 
long long octn = 00'23'00ll;
long long binn = 0b1010'0011ll;

Single quotes mark are ignored when determining its value.

Example:

The position of the single quotes is irrelevant. All the following are equivalent:

long long a1 = 123456789ll;
long long a2 = 123'456'789ll; 
long long a3 = 12'34'56'78'9ll;
long long a4 = 12345'6789ll;

It is also allowed in user-defined literals:

std::chrono::seconds tiempo = 1'674'456s + 5'300h;

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Digit separators:
* Digit Separator

Table Of Contents
8 Arrays
11 Loops
39 Streams
51 Unions
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
84 RTTI
87 Scopes
104 Profiling
107 Recursion
117 Iteration
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype
143 Digit separators