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

Правка en2, от Kaleab_Asfaw, 2020-07-27 13:49:49

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

n % k = n & (k-1)

Example

I wasn't able to proof this statement, how could it be proofed without taking number as example?

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)