Expand description
Binary-coded decimal (BCD) codec for DVB wire fields.
DVB packs many numeric fields as BCD — each 4-bit nibble holds one decimal digit (0–9). Examples: the HHMMSS of a UTC time, the frequency / symbol-rate of the delivery-system descriptors, the HHMM of a local-time offset. These helpers convert between the packed BCD representation and plain integers in both directions so callers never hand-decode nibbles.
Every decode has a symmetric encode; both reject out-of-range input by
returning None rather than producing garbage.
Constants§
- MAX_
NIBBLES - Largest number of BCD nibbles representable in the
bcd_to_decimal/decimal_to_bcdu64carrier.
Functions§
- bcd_
to_ decimal - Decode the low
nibblesBCD digits ofrawto a decimal value. - decimal_
to_ bcd - Encode
valueasnibblespacked-BCD digits in the low bits of au64. - from_
bcd_ byte - Decode a packed-BCD byte (two nibbles) to
0..=99. - to_
bcd_ byte - Encode
0..=99to a packed-BCD byte.