diff --git a/code/c++/outputFormatted.cpp b/code/c++/outputFormatted.cpp new file mode 100644 index 0000000..58b21b7 --- /dev/null +++ b/code/c++/outputFormatted.cpp @@ -0,0 +1,21 @@ + +// formatted outut looks awful before c++20 + +#include +#include +#include + +int main() { + double d = 50.0123456789; + + std::string s; + std::stringstream sstream; + sstream.setf(std::ios::fixed); + sstream.precision(10); + sstream << d; + + s = sstream.str(); + std::cout << d << std::endl; + std::cout << s << std::endl; + return 0; +}