I want to transmit values over an error prone channel. When transmitting analog values, the precision degrades smoothly when the transmission becomes worse. But when transmitting binary integers, an error in the first bit has catastrophic consequences.
Now say I want to transmit an 8 bit integer, I could transmit 256 bits and count the number of set bits. This will replicate the analog experience. But I was wondering if there is a code that keeps this quality but manages to reconstruct some more information when there are no errors.
I've been looking at the Gray code, but it's not quite what I want. And I was considering to look at higher frequencies of of the bit patterns to recover more information. E.g. to recover more of an 8 bit value v
:
(popcount(v)<<5) + ((popcount(v>>4)+4-popcount(v>>4))<<2)
But this also does not quite work out, because very high and very low values don't have higher frequency components. It works very well for the values in between however.
Anyways there must be a binary code that maps to integers and degrades gracefully, I just can't seem to find it.