CKTIS / C
Bitwise AND operator (&)
The binary & operator keeps only bits set in both integer operands. One common use is masking bits.
Version: C23; repository compiler flag, production runtime not attested
Syntax
left & rightThe operator left & right requires integer operands. After the usual arithmetic conversions, a result bit is set only when both corresponding bits are set. These conversions determine the result type.
In the example, 13u & 6u yields 4u: 1101 & 0110 yields 0100. Prefer unsigned types for masks. Test (value & mask) != 0u; parentheses matter because != has higher precedence than &.
Do not confuse & with logical &&: & neither short-circuits nor guarantees operand evaluation order. Unary &value takes an address—it is a different operator.
Examples
#include <stdio.h>
int main(void)
{
unsigned int value = 13u;
unsigned int mask = 6u;
unsigned int result = value & mask;
printf("%u\n", result);
printf("%d\n", (value & mask) != 0u);
return 0;
}
Result
4 1
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.