CKTIS / C
Bitwise XOR operator (^)
The ^ operator compares corresponding bits of two integers. A result bit is 1 when the operand bits differ.
Version: C23; repository compiler flag, production runtime not attested
Syntax
a ^ ba ^ b performs bitwise exclusive OR: 0 ^ 0 and 1 ^ 1 produce 0, while 0 ^ 1 and 1 ^ 0 produce 1. Both operands must have integer types; the usual arithmetic conversions occur before the operation.
^ is neither exponentiation nor logical XOR of truth values. A mask toggles bits where it contains 1, leaving other bits unchanged. In the example, 12u has low bits 1100 and 10u has 1010; XOR produces 0110, or 6.
Examples
#include <stdio.h>
int main(void)
{
unsigned int value = 12u;
unsigned int mask = 10u;
printf("%u\n", value ^ mask);
return 0;
}
Result
6
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.