Floating point format for std::ostream

std::cout << std::fixed << std::setw(11) << std::setprecision(6) << my_double;

You need to add

#include <iomanip>

You need stream manipulators

You may “fill” the empty places with whatever char you want. Like this:

std::cout << std::fixed << std::setw(11) << std::setprecision(6) 
          << std::setfill('0') << my_double;

Leave a Comment