-2

I print double to stringstream this way::

std::stringstream message;
message << sss[j]->stocks << '/' << std::setprecision(5) << sss[j]->profit << '/' << sss[j]->lastPrice;
std::cout << std::setw(30) << message.str();

sss[j]->profit is double. I want it to be printed "without E", but in output I still have something like this:

-560000/4.076e+005/0.7394

How to avoid e?

Oleg Vazhnev
  • 23,239
  • 54
  • 171
  • 305
  • Change the [format](http://en.cppreference.com/w/cpp/io/manip/fixed). – chris Jun 08 '14 at 21:13
  • 1
    By reading the [relevant pages of the manual](http://en.cppreference.com/w/cpp/io/manip/fixed) – Csq Jun 08 '14 at 21:13
  • 1
    Exact duplicate of [How to keep doubles from converting to scientific notation when using and stringStream](http://stackoverflow.com/questions/6010838/how-to-keep-doubles-from-converting-to-scientific-notation-when-using-and-string) – Csq Jun 08 '14 at 21:14

1 Answers1

1

Use std::fixed

std::cout << std::fixed << sss[j]->stocks << std::endl;

And btw the "e" comes from the so called scientific-notation.

Stefan Falk
  • 23,898
  • 50
  • 191
  • 378