thebigjuicyd's blog

By thebigjuicyd, history, 4 years ago, In English

I just participated in the Div 2 Algo Muse Comp and on question 3, you could use &=. But the &= was not used with booleans. It was used with int, like a &= n — 1; What does the &= mean and do in this int context?

  • Vote: I like it
  • -11
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it +18 Vote: I do not like it

a &= n-1 is same as a = a & (n-1) it is called bit-wise and.

»
4 years ago, # |
  Vote: I like it +4 Vote: I do not like it

Google and read about bitwise operators.