3

Sometimes in C++ I want to use large number like 1000000 and it's confusing. How can I use commas (if that is possible)?

For example I want this to work

int x = 1,000,000;
cigien
  • 57,834
  • 11
  • 73
  • 112

1 Answers1

6

You an use the digit separator since c++14

int x = 1'000'000 

Does this work for you?

fabian
  • 1,413
  • 1
  • 13
  • 24
  • What if I used them wrong like: int x=1'0? –  Jun 20 '21 at 12:33
  • 3
    @ariel • `int x=1'0;` is not using them wrong. They are intended to be a separator for readability. Cosmetic, like a comment. That's an unusual grouping, but isn't wrong. – Eljay Jun 20 '21 at 12:36