The following code displays floating-point numbers in scientific notation:
float foo = 1.0;
::cout::setf(::std::ios::scientific);
::std::cout << foo;
It produces this output:
1.000000e-000
What I would like to do is display floating-point numbers in a specific notation which resembles the scientific notation but with a mantissa set to zero. With the same floating-point number as above, it would produce:
0.100000e+001
In C, I believe it would be written this way:
printf("%.6E", foo);
Update: Well, actually I don't know how to do it in C as well. Update2: The example using iostream formatting was incorrect. I modified it according to Michael Burr's comment.