How to display floating-point numbers with a mantissa set to zero in C++?
<p>The following code displays floating-point numbers in scientific notation:</p>

<pre><code>float foo = 1.0;
::cout::setf(::std::ios::scientific);
::std::cout &lt;&lt; foo;
</code></pre>

<p>It produces this output:</p>

<pre><code>1.000000e-000
</code></pre>

<p>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:</p>

<pre><code>0.100000e+001
</code></pre>

<p>In C, I believe it would be written this way:</p>

<pre><code>printf("%.6E", foo);
</code></pre>

<p>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.</p>
