fork(1) download
  1. #include <assert.h>
  2.  
  3. unsigned int mod_power_of_two(unsigned int a, unsigned int b)
  4. {
  5. //assert(b && (b & (b - 1)) == 0);
  6. return a & (b - 1);
  7. }
  8.  
  9. unsigned int mod(unsigned int a, unsigned int b)
  10. {
  11. return a % b;
  12. }
  13.  
  14. int main()
  15. {
  16. assert(mod_power_of_two(17, 1) == mod(17, 1));
  17. assert(mod_power_of_two(17, 2) == mod(17, 2));
  18. assert(mod_power_of_two(17, 4) == mod(17, 4));
  19. assert(mod_power_of_two(17, 8) == mod(17, 8));
  20. return 0;
  21. }
Success #stdin #stdout 0s 4400KB
stdin
Standard input is empty
stdout
Standard output is empty