title: Why is modulus handle differently int and enum?
body: <p>If you run the following code, you'll see that modulus result can be negative on an integer, but is always positive on an enum.</p>
  
  <p>It's ok for my case (I use it to cycle through a menu list of options), but I'd like to be sure that it is an ANSI constraint, and not a compiler implementation.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  enum targets {
      TARGET1,
      TARGET2,
      TARGET3,
      TARGET4,
      NUMTARGETS,
  };
  
  int main() {
      int i;
      enum targets selected_enum = TARGET3;
      int selected_int = TARGET3;
  
      for (i = 0; i &lt; 10; i++) {
          selected_enum = (selected_enum - 1) % NUMTARGETS;
          printf("Selected_enum = %d\n", selected_enum); /* I only see positive values */
      }
  
      for (i = 0; i &lt; 10; i++) {
          selected_int = (selected_int - 1) % NUMTARGETS;
          printf("Selected_int = %d\n", selected_int); /* I see negative values */
      }
  
      return 0;
  }
  </code></pre>