Search code examples
c++fmt

Is it possible to format number with thousands separator using fmt?


Is it possible to format number with thousands separator using fmt?

e.g. something like this:

int count = 10000;
fmt::print("{:10}\n", count);

update

I am researching fmt, so I am looking for solution that works with fmt library only, without modify locale in any way.


Solution

  • I found the answer online in Russian forum:

    int count = 10000;
    fmt::print("{:10L}\n", count);
    

    This prints:

    10,000
    

    The thousands separator is locale depended and if you want to change it to something else, only then you need to "tinker" with locale classes.