[ create a new paste ] login | about

Link: http://codepad.org/EjZTw6lR    [ raw code | output | fork | 1 comment ]

pjohnmeyer - C++, pasted on Mar 4:
#include <sstream>
#include <iomanip>

class mystringstream : public std::stringstream
{
public:
  mystringstream()
  {
    precision(16);
  }
};


int main()
{
  std::stringstream stream;
  mystringstream mystream;
  double pi = 3.141592653589793;
  double e  = 2.718281828459045;

  stream << pi << ", " << e << std::endl;
  mystream << pi << ", " << e << std::endl;
  
  std::cout << stream.str();
  std::cout << mystream.str();
}


Output:
1
2
3.14159, 2.71828
3.141592653589793, 2.718281828459045


Create a new paste based on this one


Comments:
posted by pjohnmeyer on Mar 4
reply