title: pow(); function causing inconsistent results
body: <p>This is the code:</p>
  <pre class="lang-c prettyprint-override"><code>#define _CRT_SECURE_NO_WARNINGS
  
  #include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  int findIntLen(int num); // A function that finds the amount of digits an integer has.
  
  int main(void)
  {
      int num = 0, temp = 0, res = 0;
      int index = 0, digit = 0;
  
      // Receive a number to be flipped from the user.
      do
      {
          printf(&quot;Please enter a positive integer to be flipped: &quot;);
          scanf(&quot;%d&quot;, &amp;num);
          getchar();
      } while (num &lt; 1);
  
      temp = num;              // Assign the number value to a temporary variable so we do not lose our original value.
      index = findIntLen(num); // Generate an index variable that will be modified on each iteration.
      while (index &gt; 0)
      {
          digit = temp % 10;                 // Find the next digit.
          res += digit * pow(10, index - 1); // Add the correct value to the result variable.
          temp = temp / 10;                  // Divide the temporary variable by 10 so we check the next digit on the next iteration.
          index--;                           // Subtract 1 from the index to multiply by correct power of 10 on next iteration.
      }
      /*  Example of the idea:
          if number is 15:
          digit count would be 2 therefor initial index would be 1.
          res += 5 * pow(10, 1) =&gt; 5 * 10 = 50
  
          * Next Iteration *
          Index is now 0:
          res += 1 * pow(10, 0) =&gt; 1 * 1 = 1
  
          FINAL RESULT: 51
      */
  
      printf(&quot;Flipped %d = %d\n&quot;, num, res); // Print final result.
  
      return 0;
  }
  
  int findIntLen(int num)
  {
      int len = 0;
  
      while (num != 0)
      {
          num /= 10;
          len++;
      }
  
      return len;
  }
  </code></pre>
  <p><strong>When I run it using Visual Studio it works fine, but when i compile it with gcc the final digit seems to get subtracted by 1.</strong></p>
  <p><a href="https://i.stack.imgur.com/15FUs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/15FUs.png" alt="A non working example in using gcc" /></a></p>
  <p><a href="https://i.stack.imgur.com/0mp8x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0mp8x.png" alt="A working example in visual studio" /></a></p>
  <p><strong>The program is intended to receive an integer and flip it, then print the new integer, like so:</strong></p>
  <p><a href="https://i.stack.imgur.com/NxjJu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NxjJu.png" alt="Correct run of the program" /></a></p>
  <p>If anyone knows what the origin of this problem may be I would love to know.
  I am using <code>Visual Studio 2019</code>, gcc version <code>gcc (MinGW.org GCC-6.3.0-1) 6.3.0</code> and all running on a <code>Windows 10</code> pc.</p>