title: The modulo operation doesn't seem to work on a 64-bit value of all ones
body: <p>So... the modulo operation doesn't seem to work on a 64-bit value of all ones.</p>
  
  <p>Here is my C code to set up the edge case:     </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char *argv[]) {
      long long max_ll =   0xFFFFFFFFFFFFFFFF;
      long long large_ll = 0x0FFFFFFFFFFFFFFF;
      long long mask_ll =  0x00000F0000000000;
  
      printf("\n64-bit numbers:\n");
      printf("0x%016llX\n", max_ll % mask_ll);
      printf("0x%016llX\n", large_ll % mask_ll);
  
      long max_l =   0xFFFFFFFF;
      long large_l = 0x0FFFFFFF;
      long mask_l =  0x00000F00;
  
      printf("\n32-bit numbers:\n");
      printf("0x%08lX\n", max_l % mask_l);
      printf("0x%08lX\n", large_l % mask_l);
  
      return 0;
  }
  </code></pre>
  
  <p>The output shows this:</p>
  
  <pre><code>64-bit numbers:
  0xFFFFFFFFFFFFFFFF
  0x000000FFFFFFFFFF
  
  32-bit numbers:
  0xFFFFFFFF
  0x000000FF
  </code></pre>
  
  <p>What is going on here? </p>
  
  <p><s>Why doesn't modulo work on a 64-bit value of all ones, but it will on a 32-bit value of all ones?</s></p>
  
  <p>It this a bug with the Intel CPU? Or with C somehow? Or is it something else?</p>
  
  <h2>More Info</h2>
  
  <p>I'm on a Windows 10 machine with an Intel i5-4570S CPU. I used the <code>cl</code> compiler from Visual Studio 2015.</p>
  
  <p>I also verified this result using the Windows Calculator app (Version 10.1601.49020.0) by going into the Programmer mode. If you try to modulus <code>0xFFFF FFFF FFFF FFFF</code> with anything, it just returns itself.</p>
  
  <p><s>Specifying unsigned vs signed didn't seem to make any difference.</s></p>
  
  <p>Please enlighten me :) I actually did have a use case for this operation... so it's not purely academic.</p>