2) It should then find the smallest number of parity bits needed to do the job.
Example: m = 12 bits data
If r = 3 parity bits, max number of data bits is 2r-1-r = 4, not sufficient for 12 bits
If r = 4 parity bits, max number of data bits is 2r-1-r = 11, not sufficient for 12 bits
If r = 5 parity bits, max number of data bits is 2r-1-r = 26, sufficient for 12 bits
Thus use 12 bits data + 5 bits parity, total length n = 17; i.e. a (17,12) code.
3) The program should create an n-bit array where bit positions that are powers of 2 are reserved for parity bits.
4) Place the m data bits in the remaining (i.e.) non-parity bit positions and compute the parity bit values.