The C equivalent of the Go expression x &^ y
is just x & ~y
. That is literally “x
AND (bitwise NOT of y
)”.
In the arithmetic operators section of the spec describes &^
as a “bit clear” operation, which gives an idea of what you’d want to use it for. As two separate operations, ~y
will convert each one bit to a zero, which will then clear the corresponding bit in x
. Each zero bit will be converted to a one, which will preserve the corresponding bit in x
.
So if you think of x | y
as a way to turn on certain bits of x
based on a mask constant y
, then x &^ y
is doing the opposite and turns those same bits off.