Skip to main content
The & symbol in C represents two distinct operators depending on its lexical context and arity: the unary address-of operator, which yields the memory address of its operand, and the binary bitwise AND operator, which performs a bit-by-bit logical conjunction on two integer operands.

Unary & (Address-of Operator)

When used as a prefix unary operator, & evaluates to the memory address of its operand, effectively generating a pointer value that points to that object within the C abstract machine.
Technical Mechanics:
  • Operand Constraints: The operand must be a valid lvalue (an expression that designates an object with an identifiable memory location), a function designator, or an array name.
  • Restrictions: The unary & cannot be applied to expressions that are not lvalues (such as literal constants or temporary expression results), bit-fields within a struct, or variables explicitly declared with the register storage class specifier.
  • Type Evaluation: If the operand is of type T, the resulting expression &operand evaluates to a value (which is not an lvalue) of type T* (pointer to T).
Code Example:

Binary & (Bitwise AND Operator)

When used as an infix binary operator, & performs a bitwise logical AND operation. It compares the binary representations of two operands bit-by-bit, yielding a new value based on strict logical conjunction.
Technical Mechanics:
  • Operand Constraints: Both operands must be of integral types (e.g., char, short, int, long, or their unsigned variants). The operator cannot be applied to floating-point types, pointers, or aggregate types.
  • Type Promotion: Prior to the operation, the compiler applies the usual arithmetic conversions to both operands to establish a common type. The result of the expression evaluates to this common promoted integral type.
  • Evaluation Logic: For each corresponding bit position in the promoted operands, the resulting bit is set to 1 if and only if both operand bits are 1. Otherwise, the resulting bit is 0.
Code Example:
Tired of Poor C Skills? Fix That With Deep Grasping!Learn More