Most optimized way to calculate modulus in C

后端 未结 8 1305
逝去的感伤
逝去的感伤 2020-12-08 15:39

I have minimize cost of calculating modulus in C. say I have a number x and n is the number which will divide x

when n == 65536 (which happens to be 2^16):

m

8条回答
  •  佛祖请我去吃肉
    2020-12-08 16:04

    The bitwise operation only works well if the divisor is of the form 2^n. In the general case, there is no such bit-wise operation.

提交回复
热议问题