how to proof x & -x is a power of two don't larger than x
Difference between en1 and en2, changed 77 character(s)
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 searched google and don't have any more knowledge that `it is a trick.`↵

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.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English shuneo 2023-03-19 19:35:17 77
en1 English shuneo 2023-03-19 19:32:40 499 Initial revision (published)