m & (n - 1) doesn't seem to work as m % (pow(2, n))
calebsander opened this issue · 2 comments
calebsander commented
I assume "Modulo 2n against m" means m % (pow(2, n))
. In that case, for m=11
and n = 3
, m & (n - 1)
gives 2
, but 11 % 8
gives 3
. Perhaps you mean m & ((1 << n) - 1)
?
keon commented
Thanks guys.
I am closing this issue since it is solved.