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

  • Home
  • SEARCH
  • 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 8614511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:08:17+00:00 2026-06-12T05:08:17+00:00

In C++, when I do std::cout << 1.2; what is the actual chain of

  • 0

In C++, when I do

std::cout << 1.2;

what is the actual chain of functions that are called to actually display the number? I realize this is compiler specific, but I am interested in particular with the Gnu libstdc++ implementation.

In C, calling printf delegates to vfprintf, which through jump tables calls __printf_fp in glibc. I’m looking for an analogous chain in the pure C++ setting.

  • 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-12T05:08:18+00:00Added an answer on June 12, 2026 at 5:08 am

    Clearly, it will call ostream::operator<< first but it may be library specific beyond that. The best way to answer this is to debug into the code and follow the functions as they occur. This will not only tell you what functions are called but tell your about edge cases and error handling that occurs. Looking at the code may help but it is likely convoluted.

    Using this code:

    std::cout << 1.2f;
    

    … here is what is does in Visual Studio 2012 without the noise:

    1. operator<<(float _Val) (std::basic_ostream<_Elem, _Traits>)
      1. Initialize a state variable to good.
      2. Call use_facet<_Facet>(const locale & _Loc) (std) to get the num_put facet.
      3. Call num_put(_OutIt _Dest, ios_base& _Iosbase, _Elem _Fill, double _Val) (std) to write the float to the output stream (converted to a double) using local specific formatting. Internally, this:
        1. Checks the precision, such fixed, to see if the default formatting has been modified.
        2. Formats the number and writes it to the output as characters to the current iterator used by the stream.
      4. Set the state variable to bad if the operation failed.
      5. Call setstate to the state.

    So most of the work is actually done in the num_put facet, which writes to an iterator for the output stream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a code that uses unique_ptr: struct Foo{ Foo(){std::cout << Ctor called\n;} ~Foo(){std::cout
I am curious if std::cout has a return value, because when I do this:
class foo { public: void say_type_name() { std::cout << typeid(this).name() << std::endl; } };
std::map<std::string, int> m; // Can I make assumption that m[NoSuchKey] will return 0? std::cout
For whatever reason, std::cout does not display anything with my application. The description of
For this program #include <iostream> using std::cout; struct C { C() { cout <<
I'm having some issues with std::cout, std::stringstream, and std::string.c_str(). Mainly, it seems that there's
I have this code: char* hello = Hello World; std::cout << Pointer value =
I have this example code that doesn't compile: #include <iostream> #include <vector> using std::endl;
It looks like std::cout can't print member function's address, for example: #include <iostream> using

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.