Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8841567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:45:02+00:00 2026-06-14T10:45:02+00:00

I can do locale loc(); // use default locale cout.imbue( loc ); cout <<

  • 0

I can do

locale loc(""); // use default locale
cout.imbue( loc );
cout << << "i: " << int(123456) << " f: " << float(3.14) << "\n";

and it will output:

i: 123.456 f: 3,14

on my system. (german windows)

I would like to avoid getting the thousands separator for ints — how can I do this?

(I just want the users default settings but without any thousands separator.)

(All I found is how to read the thousands separator using use_facet with the numpunct facet … but how do I change it?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:45:04+00:00Added an answer on June 14, 2026 at 10:45 am

    Just create and imbue your own numpunct facet:

    struct no_separator : std::numpunct<char> {
    protected:
        virtual string_type do_grouping() const 
            { return "\000"; } // groups of 0 (disable)
    };
    
    int main() {
        locale loc("");
        // imbue loc and add your own facet:
        cout.imbue( locale(loc, new no_separator()) );
        cout << "i: " << int(123456) << " f: " << float(3.14) << "\n";
    }
    

    If you have to create a specific output for another application to read, you may also want to override virtual char_type numpunct::do_decimal_point() const;.

    If you want to use a specific locale as base, you can derive from the _byname facets:

    template <class charT>
    struct no_separator : public std::numpunct_byname<charT> {
        explicit no_separator(const char* name, size_t refs=0)
            : std::numpunct_byname<charT>(name,refs) {}
    protected:
        virtual string_type do_grouping() const
            { return "\000"; } // groups of 0 (disable)
    };
    
    int main() {
        cout.imbue( locale(std::locale(""),  // use default locale
            // create no_separator facet based on german locale
            new no_separator<char>("German_germany")) );
        cout << "i: " << int(123456) << " f: " << float(3.14) << "\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can output a locale sensitive time format using strftime('%X') , but this always
In Python I can use locale.format to pretty-print numbers according to locale setting: >>>
Can you suggest me the API to get the system language and system locale
I know I can use the lang parameter to automatically change the current locale
As we know, in windows system, we can set locale language for non-Unicode programs
Can the locale configuration of a system OR the keyboard type configuration of that
I can print out a date nicely based on the user's locale. But how
How can I display the time in the current app locale using Calendar? For
In C++, I can set the current locale like this: std::locale::global(std::locale(name)) But how can
I want to get the numpunct<char> facet for the native locale. I can generate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.