Representing repeated values by run length

A general sequence can encode a consecutive run as a value and repetition count. Decoding emits the value that many times. Scattered occurrences are not one run merely because the same symbol appears elsewhere.

For binary data, a format can alternate zero and one runs and store only lengths. Princeton starts with a zero run, so an input beginning with one needs an initial zero-length zero run to preserve the decoder’s alternation.

References: [1]

Bounded counters require a splitting rule

An unsigned eight-bit counter holds zero through 255. Princeton’s alternating-bit format splits longer runs with a 255 count followed by a zero-length opposite run, then continues the original bit. This avoids overflow without changing reconstructed data.

Other formats can use explicit symbols, variable-length counts or escape conventions. The zero-run technique is one format, not a universal byte layout. Both sides must agree on counter limits, splits and termination.

References: [1]

Short runs can amplify overhead

Near-alternating bits can require a whole count byte for each original bit, expanding the data. Long runs offer the opposite opportunity, so effectiveness depends on local repetition.

Compression pipelines can transform data to encourage runs before this step. A damaged count can nevertheless cause a long incorrect expansion. Exact decoding of valid input does not itself supply output-size limits or transmission-error detection.

References: [1] [2]