What is proof for finding remainder(%) when n divide by k, if k is power of two.

Правка en1, от Kaleab_Asfaw, 2020-07-27 13:37:18

For any integer n and where k is power of 2,

n % k = n & (k-1)

I wasn't able to proof this statement, how could it be proofed?

Thanks in Advance!

Теги #modulo, #bitwise

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Kaleab_Asfaw 2020-07-27 13:49:49 235 Tiny change: 'oofed with out taking' -> 'oofed without taking'
en1 Английский Kaleab_Asfaw 2020-07-27 13:37:18 250 Initial revision (published)