3 ms·
const uintSize = 32 << (^uint(0) >> 32 & 1) > If we’re on a 64 bit platform then the exclusive or of the number zero–all zero bits–is a number with all bits se
by ohazi 7y ago
const uintSize = 32 << (^uint(0) >> 32 & 1)
> If we’re on a 64 bit platform then the exclusive or of the number zero–all zero bits–is a number with all bits set, sixty four of them to be exact.
That's not exclusive or, that's bitwise complement (~ in C). Go reuses the carat symbol for this, but xor needs two inputs.
- clappski 7y agoWhy does Go redefine `^` to mean something that it doesn't mean in all the programming languages I know? Is there a reason that xor isn't `^`?