In this article, we will discuss the use of a digit separator in C++. Sometimes, it becomes difficult to read numbers that contain many digits. For example, 1000 is readable but what if more zeros are added to it, let’s say 1000000, now it becomes a little difficult to read, and what will happen if more zeros are added to it. In real life, commas (, ) are added to the number. For Example: 10, 00, 000. Now it is easy to read, that is ten lakhs.
Now the question arises that C++ doesn’t accept such separators (comma) so how to deal with big numbers. To deal with it, C++14 has introduced a feature and its name is Digit Separator and denoted by a simple quotation mark (‘). This can make it easier for users to read large numbers.
Below is the implementation to show that single quote marks are ignored when determining their value:
Below is the program to show that Single quote marks are just for users. Using them in any position does not affect the compiler.
a:123456 b:123456 c:123456