title: Is MOD operation more CPU intensive than multiplication?
body: <p>Why is a mod (<code>%</code>) operation more expensive than a multiplication (<code>*</code>) by a bit more than a <strong>factor of 2</strong>?</p>
  <p>Please be more specific about how CPU performs division operation and returns the result for MOD operation.</p>
  <p>In the following  example the threads each run for a second. The test was performed on a <code>SPARC</code> processor.</p>
  <pre><code>// multiplication
  void someThread() {
  
      int a = 10234;
      while (true) {
          opers++;
          a = a * a;
          a++;
      }
  
      // opers ~ 26 * 10^6 in a sec.
  }
  
  // MOD
  void someThread() {
  
      int a = 10234;
      while (true) {
          opers++;
          a = a % 10000007;
          a++;
      }
  
      // opers ~ 12 * 10^6 in a sec.
  }
  </code></pre>