Excess-3 BCD Converter

Encode decimal digits in Excess-3 (Stibitz code) BCD format

Ad placeholder (leaderboard)

Excess-3 code (XS-3, or the Stibitz code) is a binary-coded decimal representation in which every decimal digit is stored as its value plus three, written in four bits. This converter encodes decimal numbers to Excess-3 and decodes Excess-3 nibbles back to decimal, showing the offset for each digit.

How it works

To encode, the tool takes each decimal digit, adds three, and writes the result as a 4-bit binary number. So 0 becomes 0011 (0 + 3), 5 becomes 1000 (5 + 3), and 9 becomes 1100 (9 + 3). Each digit always uses exactly one nibble, and the nibbles are joined to form the code.

To decode, the input is split into 4-bit groups. Each group is read as a binary value, three is subtracted, and the difference is the decimal digit. A group whose value falls outside the range 3 to 12 is not a legal Excess-3 code, so the decoder reports it instead of producing a wrong digit.

The self-complementing property

The reason for the offset of three is elegant. In Excess-3 the bitwise complement of a digit’s nibble gives the nines complement of that digit. For example digit 2 is 0101; inverting the bits gives 1010, which is 10 in binary and decodes to 10 - 3 = 7, exactly the nines complement of 2. This let early relay computers, including those built by George Stibitz at Bell Labs, perform decimal subtraction using only addition and bit inversion.

Example

The number 259 encodes digit by digit:

2 -> 2 + 3 = 5  -> 0101
5 -> 5 + 3 = 8  -> 1000
9 -> 9 + 3 = 12 -> 1100

So 259 in Excess-3 is 0101 1000 1100. Decoding reverses each step. Everything is computed locally in your browser.

Ad placeholder (rectangle)