# Hamming Codes

## Parity Bit

A parity bit indicates whether the number of 1s in the data is even (0) or odd (1).

By checking the value against the data any odd number of bit switches (data corruption) can be detected.

For example if the first bit is used as a parity bit:

```
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
```

```
1 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0
```

## Hamming Codes

Additional parity bits are introduced for groups of data bits for space efficient error detection. Even the error position can be identified.

- Pos 1: odd positions/odd columns
- Pos 2: right side of the block
- Pos 4: odd rows
- Pos 8: bottom rows

Odd number of positions