TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
| operator in C is the bitwise inclusive OR operator. It performs a logical disjunction on each pair of corresponding bits of two integral operands. If either or both bits in the compared position are 1, the resulting bit is 1; if both bits are 0, the resulting bit is 0.
Truth Table
The operator evaluates operands at the binary level according to the following truth table: | Bit A | Bit B | A| B |
| :---: | :---: | :---: |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Operand Constraints
The| operator strictly requires operands of integral types (e.g., char, short, int, long, unsigned variants, and _Bool). Attempting to use the | operator with floating-point types (float, double) or pointer types will result in a compilation error.
Integer Promotion and Type Conversion
Before the bitwise OR operation is executed, C applies standard integer promotions to the operands:- If the operands are of types smaller than
int(such ascharorshort), they are promoted tointorunsigned int. - If the operands are of different types, the compiler applies the usual arithmetic conversions to establish a common type.
- The operation is then performed, and the resulting value shares this common promoted type.
Evaluation Mechanics
When evaluatinga | b, the compiler aligns the bit sequences of both operands and applies the OR logic vertically to each bit index.
Compound Assignment
The bitwise OR operator can be combined with the assignment operator to form the compound assignment operator|=. This mutates the left operand by applying the bitwise OR operation between it and the right operand.
Master C with Deep Grasping Methodology!Learn More





