Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 29th, 2012  |  syntax: None  |  size: 0.17 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to efficiently calculate a modulus in C by hand?
  2. unsigned int modulus = (a - (INT_FLOOR(a / b) * b) + b) % b;
  3.        
  4. unsigned int modulus = (a - (a & ~(b-1)) + b) & (b-1);