in go lang, why this is 7 ?
assert(5^2 == 7)
so strange. I tried to google it. but google does not work well with special characters. Thanks.
in go lang, why this is 7 ?
assert(5^2 == 7)
so strange. I tried to google it. but google does not work well with special characters. Thanks.
The ^
operator is the XOR (exclusive OR), applied bitwise if operands are numbers.
5 = 101b // in binary, but Go doesn't have binary literals
2 = 010b
XOR:
7 = 111b