Is there a way to write a large number in C++ source code with spaces to make it more readable? [duplicate]

  • A+

Imagine I have the code:

vector<int> temp = vector<int>(1 000 000 000); 

The above will not compile as the compiler will complain about the spaces. Is it possible to indicate to C++ to ommit those spaces when compiling, or otherwise make the number easier to read?

Try digit separator:

int i = 1'000'000'000; 

This feature is introduced since C++14. It uses single quote (') as digit separator.

Also see:


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: