Binary ^ operators are predefined for the integral types and bool. For integral types, ^ computes the bitwise exclusive-OR of its operands. For bool operands, ^ computes the logical exclusive-or of its operands; that is, the result is true if and only if exactly one of its operands is true.
and explanation of example.
0xf8 is hex and in binary it is 11111000 0x3f is hex and in binary it is 00111111 and the result is 0xc7 is hex and in binary it is 11000111
Compare the value by bits.
Ex:
1 ^ 0 result is 1 1^1 result is 0
As you can see if only one of bits is true the result is true otherwise false.
Marqué comme réponserecherchesamedi 7 novembre 2009 17:35
Binary ^ operators are predefined for the integral types and bool. For integral types, ^ computes the bitwise exclusive-OR of its operands. For bool operands, ^ computes the logical exclusive-or of its operands; that is, the result is true if and only if exactly one of its operands is true.
and explanation of example.
0xf8 is hex and in binary it is 11111000 0x3f is hex and in binary it is 00111111 and the result is 0xc7 is hex and in binary it is 11000111
Compare the value by bits.
Ex:
1 ^ 0 result is 1 1^1 result is 0
As you can see if only one of bits is true the result is true otherwise false.
Marqué comme réponserecherchesamedi 7 novembre 2009 17:35