title: C++ Write a long float number to a file
body: <p>file.txt</p>
  
  <pre><code>123.56
  89.78
  8.89
  468.98
  567.90
  5.78
  178908.90
  12.56
  6789.90
  12.56
  16.780
  0.00
  </code></pre>
  
  <p>I've parsed the numbers into an array called float A[150] = {0}.
  So, A looks like:</p>
  
  <pre><code>A[0] = 123.56
  A[1] = 89.78
  ....
  ....
  A[10] = 16.780
  A[11] = 0.00
  A[12] = 0
  A[13] = 0
  ...
  ...
  </code></pre>
  
  <p>Then, I have a sorting Algorithm</p>
  
  <pre><code>Sort(A, i) // where i is the number of elements (12)
  </code></pre>
  
  <p>Now A[] looks like</p>
  
  <pre><code>A[0] = 0
  A[1] = 5.78
  ...
  ...
  A[10] = 6789.90
  A[11] = 178908.90
  </code></pre>
  
  <p>Then, I write it to a file called "Final.txt"</p>
  
  <pre><code>std::ofstream File (Name);
  if (File.is_open())
      {
          for (j = 0; j &lt; i; j++)
          {
              File &lt;&lt; A[j] &lt;&lt; std::endl;
          }
      }
  </code></pre>
  
  <p>The file output "Final.txt" looks like: </p>
  
  <pre><code>0
  5.78
  8.89
  12.56
  12.56
  16.78
  89.78
  123.56
  468.98
  567.9
  6789.9
  178909 // Why it is NOT CORRECT !!!!!!!
  </code></pre>
  
  <p>The problem with A[11] after the sorting, why is it not correct in "Final.txt", even though it is correct when I debug it in the A[11] ?</p>