# Example 2: Hamming code and Parity bit

Eg.  Now form a hamming code for 5-bit information bits 10110 with odd parity

m=5 and we have to follow         2p >= m + p + 1

The value of p as 4 to satisfy 24 (16) >= 5 + 4 + 1 but p=3 doesn’t satisfy as 23 (8) >= 5 + 3 + 1

So p=4 and hence a total of 9 bits

Parity bit positions are 1, 2, 4, 8

And hence hamming code composition is as follow

0001       0010      0011      0100       0101       0110       0111       1000       1001

1              2              3              4              5              6              7              8              9

P1                P2             M1             P3              M2            M3               M4               P4             M5

Now if we see Phas 1 at LSB so message bits with this parity bit are M1 M2 M4 M5

Similarly we see P2 checks M1 M3 M4

Similarly we see P3 checks M2 M3 M4

Similarly we see P4 checks M5

Or we can also put it as

Pchecks code bits 1, 3, 5, 7, 9

Pchecks code bits 2, 3, 6, 7

Pchecks code bits 4, 5, 6, 7

Pchecks code bits 8, 9

For message 10110 we hamming code

Bit positions

1              2              3              4              5              6              7              8              9

P1               P2               1 P3             0 1 1 P4              0

We see P1=1 to make no. of 1’s to 3 i.e. odd

We see P2=0 to make no. of 1’s to 3 i.e. odd

We see P3=1 to make no. of 1’s to 3 i.e. odd

We see P4=1 to make no. of 1’s to 1 i.e. odd

So we get the hamming code as 101101110