title: math.h pow() function not working correctly?
body: <p>I was working on a personal project in which I needed to determine all <a href="http://en.wikipedia.org/wiki/Prime_power" rel="nofollow">prime powers</a> between 0 and 999. Because I am not particularly good at math, I tired the following ham-fisted bruteforce approach.  </p>
  
  <pre><code>bool constexpr is_prime(int imp)
  {
      return imp == 1 ? false : (imp % imp == 0 &amp;&amp; imp % 1 == 0 &amp;&amp; [&amp;imp]{ for(int i = 2; i &lt; imp; ++i)  if(imp % i == 0) return false; return true;}());
  }
  
  bool is_prime_power(int imp)
  {
      for(int i = 1; i &lt; 1000; ++i)
          if (is_prime(i))
              for (int j = 0; j &lt; 100; ++j)
                  if (imp == pow(i, j))
                      return true;
      return false;
  }
  </code></pre>
  
  <p>For 0...30 the output should be (according to <a href="http://oeis.org/A000961" rel="nofollow">A000961</a>):</p>
  
  <pre><code>1 2 3 4 5 7 8 9 11 13 16 17 19
  </code></pre>
  
  <p>However, this is what I get instead:</p>
  
  <pre><code>1 2 3 4 5 7 8 9 11 16 19
  </code></pre>
  
  <p>Where did 13 and 17 vanish to?</p>
  
  <p>Since I could not find any logical problems with my approach I implemented my own pow() function.</p>
  
  <pre><code>double constexpr _pow(double base, double exp)
  {
      return exp == 0 ? 1 : base*pow(base, exp - 1);
  }
  </code></pre>
  
  <p>Now if I call my version of _pow() instead of pow() from math.h the output is displayed as excepted. Is my implementation wrong? If not, pow() from math.h can't be working correctly. 
  Any idea what is causing this?</p>