When given two boolean arguments, the ^ operator performs exclusive or, e.g.
true ^ true == false
true ^ false == true
false ^ true == true
false ^ false == false
When given two numeric arguments, it does something, but I've no idea what. At first I thought it was modular division because
(5 ^ 5) == 0
However
(10 ^ 4) == 14
So it's not modular division, is it some kind of bit-shifting?
^
does the same thing as it does in Java and most other languages:
It's a bitwise exclusive OR (short: bitwise XOR)
This means that for every bit in the binary representation of the two numbers the resulting bit in the output will be the bit_in_first_value ^ bit_in_second_value
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With