title: setw of a specific integer with set precision in C++
body: <p>I'm learning the setw and setprecision functions, so here is what I've been trying so far and I have a few questions.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  int main()
  {
      float y = 1.25;
  
      cout &lt;&lt; fixed &lt;&lt; setw(10) &lt;&lt; setprecision(2) &lt;&lt; y &lt;&lt; endl;
  
      cout &lt;&lt; "\n\n\nx\n";
  
      float x = 213565544.4826;
      cout &lt;&lt; fixed &lt;&lt; setw(13) &lt;&lt; setprecision(3) &lt;&lt; x &lt;&lt; endl;
      cout &lt;&lt; fixed &lt;&lt; setw(14) &lt;&lt; setprecision(3) &lt;&lt; x &lt;&lt; endl;
      cout &lt;&lt; fixed &lt;&lt; setw(15) &lt;&lt; setprecision(3) &lt;&lt; x &lt;&lt; endl;
      cout &lt;&lt; fixed &lt;&lt; setprecision(3) &lt;&lt; x;
  
      cout &lt;&lt; "\n\n\nz\n";
  
      float z = 213565544.4826;
      cout &lt;&lt; setw(11) &lt;&lt; setprecision(1) &lt;&lt; x &lt;&lt; endl;
      cout &lt;&lt; fixed &lt;&lt; setw(12) &lt;&lt; setprecision(1) &lt;&lt; x &lt;&lt; endl;
      cout &lt;&lt; fixed &lt;&lt; setw(11) &lt;&lt; setprecision(1) &lt;&lt; x &lt;&lt; endl;
      cout &lt;&lt; setw(12) &lt;&lt; setprecision(1) &lt;&lt; x &lt;&lt; endl;
  
      cout &lt;&lt; "\n\n\nm\n";
  
      float m = -344.275;
      cout &lt;&lt; fixed &lt;&lt; setprecision(1) &lt;&lt; x &lt;&lt; endl;
      cout &lt;&lt; fixed &lt;&lt; setw(8) &lt;&lt; setprecision(1) &lt;&lt; x &lt;&lt; endl;
      cout &lt;&lt; fixed &lt;&lt; setw(7) &lt;&lt; setprecision(1) &lt;&lt; x &lt;&lt; endl;
      cout &lt;&lt; fixed &lt;&lt; setw(6) &lt;&lt; setprecision(1) &lt;&lt; x &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>And the input is :</p>
  
  <pre><code>      1.25
  
  
  
  x
  213565552.000
   213565552.000
    213565552.000
  213565552.000
  
  
  z
  213565552.0
   213565552.0
  213565552.0
   213565552.0
  
  
  
  m
  213565552.0
  213565552.0
  213565552.0
  213565552.0
  </code></pre>
  
  <p>So, now my questions are :</p>
  
  <p>1) Why do we use "fixed" in first place?</p>
  
  <p>If we look at this example:</p>
  
  <pre><code>cout &lt;&lt; setw(11) &lt;&lt; setprecision(1) &lt;&lt; x &lt;&lt; endl;
  cout &lt;&lt; fixed &lt;&lt; setw(11) &lt;&lt; setprecision(1) &lt;&lt; x &lt;&lt; endl;
  </code></pre>
  
  <p>They output the same value, so what does fixed really change?</p>
  
  <p>2) How does setw work for negative numbers?</p>
  
  <p>In the last example of m. The result is the same for all examples, what does the - sign change in the setw ?</p>
  
  <pre><code>213565552.0
  213565552.0
  213565552.0
  213565552.0
  </code></pre>
  
  <p>Where do these numbers come from? The value of m is totally different from the ones outputted.</p>
  
  <p>3) Does the . in the number counts as 1 place?</p>
  
  <p>For example, we have number 1.23 and setw(10)</p>
  
  <p>There would be 6 spaces before and then 1.23 (because the dot is counted as 1). Is that true?</p>
  
  <p>4) Why does setprecision is used along with setw? Why does 0000s appear if it's not used? Does it appear as many 0s as the float can handle?</p>
  
  <p>5) Why is the value for x</p>
  
  <pre><code>213565552.000
   213565552.000
    213565552.000
  213565552.000
  </code></pre>
  
  <p>If x = 213565544.4826.</p>
  
  <p>Where does the numbers 44.4826 get lost?</p>