Skip to content

Commit

Permalink
fmk - adding outputFormatted
Browse files Browse the repository at this point in the history
  • Loading branch information
fmckenna committed Aug 2, 2024
1 parent 4734692 commit 538fa3b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions code/c++/outputFormatted.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

// formatted outut looks awful before c++20

#include <iostream>
#include <sstream>
#include <string>

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;
}

0 comments on commit 538fa3b

Please sign in to comment.