0

I am struggling to understand what the &^ and &^= operators mean in Go. I cannot find an answer either in the documentation (which states it's a bit clear operator, but it does not help me much) or by trials.

In particular, I want to know if there is an equivalent in Python.

seh
  • 14,999
  • 2
  • 48
  • 58
Olivier Melançon
  • 21,584
  • 4
  • 41
  • 73

1 Answers1

8

These are the "AND NOT" or "bit clear" operators, "useful" for clearing those bits of the left-hand side operand that are set in right-side operand.

I put the "useful" in quotes since all other languages that derive the bitwise operations from C one does this with bitwise AND & and bitwise NOT ~; thus 5 &^ 2 would be just 5 & ~2 in Python; and a &^= 3 of Go would be a &= ~3 in Python.

Community
  • 1
  • 1