title: Why does modulus division (%) only work with integers?
body: <p>I recently ran into <a href="https://stackoverflow.com/questions/6091837/sin-and-cos-are-slow-is-there-an-alternatve/6091846#6091846">an issue</a> that could easily be solved using modulus division, but the input was a float:</p>
  
  <blockquote>
    <p>Given a periodic function (e.g. <code>sin</code>) and a computer function that can only compute it within the period range (e.g. [-π, π]), make a function that can handle any input.</p>
  </blockquote>
  
  <p>The "obvious" solution is something like:</p>
  
  <pre><code>#include &lt;cmath&gt;
  
  float sin(float x){
      return limited_sin((x + M_PI) % (2 *M_PI) - M_PI);
  }
  </code></pre>
  
  <p>Why doesn't this work? I get this error:</p>
  
   <pre class="lang-none prettyprint-override"><code>error: invalid operands of types double and double to binary operator %
  </code></pre>
  
  <p>Interestingly, it does work in Python:</p>
  
   <pre class="lang-python prettyprint-override"><code>def sin(x):
      return limited_sin((x + math.pi) % (2 * math.pi) - math.pi)
  </code></pre>