& has &&. | has ||. Why doesn\'t ^ have ^^?
I understand that it wouldn\'t
For non-bool operands, I guess what you would want is for a ^^ b to be evaluated as:
(a != 0) ^ (b != 0)
Well, you have the above option and you have a few options listed in other answers.
The operator ^^ would be redundant for bool operands. Talking only about boolean operands, for the sake of argument, let's pretend that ^ was bitwise-only and that ^^ existed as a logical XOR. You then have these choices:
& - Bitwise AND -- always evaluates both operands&& - Logical AND -- does not always evaluate both operands| - Bitwise OR -- always evaluates both operands|| - Logical OR -- does not always evaluate both operands^ - Bitwise XOR -- must always evaluate both operands^^ - Logical XOR -- must always evaluate both operandsWhy didn't they create ^^ to essentially convert numerical values into bools and then act as ^? That's a good question. Perhaps because it's more potentially confusing than && and ||, perhaps because you can easily construct the equivalent of ^^ with other operators.