title: Why does MinGW and GCC give me different outputs for this simple program?
body: <p>In a freshman CSc college course with C++, we had a problem to convert a decimal number to a binary value.</p>
  
  <p>My code for this is:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;math.h&gt;
  using namespace std;
  int main()
  {   
      int x, bin=0, i=0;
      cin&gt;&gt;x;
      while(x!=0)
      {
          bin+=(x%2)*pow(10,i++);
          x/=2;
      }
      cout&lt;&lt;bin;
      return 0;
  }
  </code></pre>
  
  <p>When I built it on Kubuntu 15.10 using gcc 5.2.1 with no extra build flags, I get the expected output of <code>10100</code> for an input of <code>20</code>.</p>
  
  <p>Yet, when I build it when MinGW packaged with CodeBlocks 13.12 on Windows 10, I get the output of <code>10098</code> for the same input of <code>20</code>.</p>
  
  <p>This bizarre deviation from the right answer increases with the number of places for the final output in MinGW. What could be going wrong and why is the MinGW output give me the wrong answer? </p>