how to proof x & -x is a power of two don't larger than x

Правка en1, от shuneo, 2023-03-19 19:32:40

Im learning BIT (Fenwick tree), i saw a expression that is x & -x to find largest power of two don't larger than x.

But i can't clear this expression, please tell me the truth. Thank you very much!

I asked GPT but it have just give example but don't proof. I've just known that this expression is a trick :'( and no more.

And more, could you give me some bitwise-research-documents? I hope that learn more about bitwise, thank you.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский shuneo 2023-03-19 19:35:17 77
en1 Английский shuneo 2023-03-19 19:32:40 499 Initial revision (published)