Encoding & Number Bases
BCD Encoder
Encode packed or unpacked BCD. Inspect digit codes, decimal place values, padding, and sign nibbles beside an independent calculation.
This tool runs open-source code from CyberChef by GCHQ (Apache License 2.0). See open-source credits.
The selected Scheme maps each decimal digit to a nibble. Signed adds a sign nibble.
The result contains the encoded value and a table of digit, sign, and padding calculations.
- Build or check a packed-decimal field, such as COBOL COMP-3 data, from a known number.
Sources: University of Deusto: BCD, Excess-3, and Aiken codes; IBM: packed decimal sign representation
Choose the BCD scheme and packing
- Enter a whole decimal number.
- Match Scheme, Packed, and Signed to the receiving format.
- Choose Output format. Bytes helps when comparing a hex dump.
Represent a signed decimal value
Input: -123
Settings: Scheme 8 4 2 1, Packed on, Signed on, Output format Bytes
Result: 00010010 00111101
In hex the bytes are 12 3D. The final nibble D marks a negative value; a positive 123 ends in C instead.
Leading zeros and digit nibbles
- The encoder removes leading zeros.
- Unsigned mode discards a minus sign.
- Signed zero uses the negative D nibble, which some formats do not expect.