# Bitwise operation facts for kids

In computer programming, a **bitwise operation** operates on a bit array at the level of its individual bits.

## Bitwise operators

In the explanations below, any indication of a bit's position is counted from the right side, moving left. For example, the binary value 0001 (decimal 1) has zeroes at every position but the first (i.e. the rightmost) one.

### NOT

The **bitwise NOT**, or **complement**, is an operation that performs logical negation on each bit. Bits that are 0 become 1, and those that are 1 become 0. For example:

NOT **0**111 (decimal 7) = **1**000 (decimal 8)

NOT 10101011 (decimal 171) = 01010100 (decimal 84)

### AND

A **bitwise AND** is an operation that takes two bit patterns and performs the logical AND operation on each pair of bits. If both bits in the compared position are 1, the result is 1 otherwise the result is 0. For example:

010**1** (decimal 5) AND 001**1** (decimal 3) = 000**1** (decimal 1)

### OR

A **bitwise OR** is an operation that takes two bit patterns of equal length and performs the logical inclusive OR operation on each pair of bits. If if both bits are 0 the result is 0, while otherwise, the result is 1. For example:

0**101** (decimal 5) OR 0**011** (decimal 3) = 0**111** (decimal 7)

### XOR

A **bitwise XOR** is an operation that takes two bit patterns of equal length and performs the logical exclusive OR operation on each pair of bits. If both bits are 0 the result 0, if one bit is 1 and the other is zero the result is 1, and if both bits are 1 the result is 0.

0**10**1 (decimal 5) XOR 0**01**1 (decimal 3) = 0**11**0 (decimal 6)

## See also

In Spanish: Operador a nivel de bits para niños

*Kiddle Encyclopedia.*