wire / wire-format / bcd

BCD (Binary-Coded Decimal)

BCD (Binary-Coded Decimal) encodes each decimal digit (0-9) as a 4-bit nibble. Packed BCD: two digits per byte (high nibble = tens, low nibble = ones). Unpacked BCD: one digit per byte (low nibble = digit, high nibble = 0 or zone). Used in financial calculations, real-time clocks, and legacy systems.

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: BCD (Binary-Coded Decimal)

wire format

spec: BCD (Binary-Coded Decimal)

BCD (Binary-Coded Decimal) encodes each decimal digit (0-9) as a 4-bit nibble. Packed BCD: two digits per byte (high nibble = tens, low nibble = ones). Unpacked BCD: one digit per byte (low nibble = digit, high nibble = 0 or zone). Used in financial calculations, real-time clocks, and legacy systems.

fieldsizemeaning
Packed BCD1 byte per 2 digitsHigh nibble = tens digit, low nibble = ones digit. E.g., 0x42 = decimal 42.
Unpacked BCD1 byte per digitLow nibble = digit, high nibble = 0 (or zone nibble 0x3 for ASCII). E.g., 0x04 = digit 4.
Sign1 nibbleFor signed BCD: the last nibble can be 0xC (+), 0xD (-), or 0xF (unsigned).
Range (packed, n bytes)n bytes2n decimal digits. E.g., 4 bytes = 8 digits (0-99999999).

example:

42

Packed BCD: 0x42 = decimal 42


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/bcd or /wire-format/bcd.json