3.1.1 Number separator

What was the problem

Long numbers are hard to read. Check how long you need to get the numbers in this C++11 code:

int wisconsin_population = 5822434; 
int california_population = 39512223;

My guess is that you grouped the digits by three in your mind in order to get the numbers right. Didn’t you? Usually when we write large numbers like that, we group the digits with a separator to make the numbers easier to read, like in 1’234’567.

How the Problem is Solved

Since C++14 we can use this syntax in the code:

int wisconsin_population = 5822434; 
int california_population = 39512223; 
 
// It works with float numbers too. 
const float f = 1111.222222; 
 
// And also with for non-decimal numbers. Funny thing, the quote can 
// appear anywhere between two digits. 
 
const unsigned mask = 0xfff000ea;