dantrim / hamming-codec

Simple encode/decode utilties for bit-error correcting Hamming codes
MIT License
14 stars 4 forks source link

Parity bit computation and the inclusive flag #10

Open dantrim opened 3 years ago

dantrim commented 3 years ago

What

The parity bit computation is inclusive during the decoding phase and not inclusive during the encoding phase. Here "inclusive" means that the bit value at the currently-being-calculated parity bit position is included in the parity computation. Right now this use of an "inclusive" flag is more or less an artifact of how the final encoded message is constructed, using a "seed" string in which all elements are initialized with a flag character (see here), with the data bits populating all positions in the seed string that are not where the redundant/parity bits will be. During the parity bit computation during the encoding phase, then, there are only valid digits (1 or 0) at the data bit positions -- the redundant positions contain the flag character and will be filled in during the encoding phase.

However, if instead of using a flag character the seed string is initialized to all 0's (a valid digit) then the need for the inclusive flag is perhaps not needed since the computation of the resulting parity will not be affected by the 0's.

To Do

Update the seed-string formation to initialize it with all 0's and then remove the inclusive flag from the parity bit computation.