Binary to Excess-3 Code Converter – Free

This binary to Excess-3 converter takes an unsigned binary integer and encodes its decimal digits as 4-bit Excess-3 groups, separated by spaces.

How to use the Binary Excess-3 Converter tool

  1. Enter an unsigned binary integer in the Binary box. Example loads 101101, which is decimal 45.
  2. Select Convert to encode the digits.
  3. Read the Excess-3 groups in the Result box. There is one 4-bit group for each decimal digit of the value.
  4. Select Copy to copy the code, or Clear to encode another number.

What Excess-3 code is

Excess-3, also written XS-3 and sometimes called the Stibitz code after George Stibitz of Bell Labs, is a way to store decimal digits in four bits. It is like binary-coded decimal with one change: every digit has 3 added before it is written in binary. Zero is 0011, five is 1000 and nine is 1100.

The offset gives the code a useful symmetry. Flipping all four bits of a digit's code yields the code of 9 minus that digit. The code for 4 is 0111, and its inverse, 1000, is the code for 5. Early decimal machines, including the UNIVAC I, used Excess-3 because it makes nine's complement subtraction simple.

How binary to Excess-3 conversion works

Excess-3 encodes decimal digits, so a binary number cannot be converted bit by bit. The tool works in three stages. It reads the input as an unsigned binary integer. It writes that integer in decimal. Then, for each decimal digit, it adds 3 and prints the sum as four bits. The groups are joined with spaces, most significant digit first. All three stages run in your browser.

Worked example: 101101

The binary input 101101 is 45. The digit 4 becomes 4 + 3 = 7, or 0111. The digit 5 becomes 5 + 3 = 8, or 1000. For comparison, plain BCD for 45 is 0100 0101, and each Excess-3 group is exactly 3 higher.

101101 (base 2) = 45 (base 10)
4 + 3 = 7  ->  0111
5 + 3 = 8  ->  1000

Result: 0111 1000

The Excess-3 code table

Only ten of the sixteen 4-bit patterns are used. The patterns 0000, 0001, 0010, 1101, 1110 and 1111 never appear in valid output. Because an all-zeros group is impossible, a dead line that reads 0000 is recognizable as a fault instead of a digit.

0 = 0011    5 = 1000
1 = 0100    6 = 1001
2 = 0101    7 = 1010
3 = 0110    8 = 1011
4 = 0111    9 = 1100

Input rules and related conversions

The Binary box accepts 1 to 65,536 binary digits. Spaces are removed and a 0b prefix is ignored. Leading zeros do not add groups, because the value is converted to decimal first: 0000 0111 is 7 and yields the single group 1010. A minus sign is not accepted, and any character other than 0 or 1 returns Enter between 1 and 65,536 binary digits.

To decode in the other direction, use the Excess-3 to Binary tool. If you want standard 8421 digits with no offset, use Binary to BCD.

Frequently asked questions

What is the Excess-3 code for 0?

It is 0011. Every digit is stored as its value plus three, so zero becomes three. The binary input 0 therefore converts to the single group 0011.

How is Excess-3 different from BCD?

Both use four bits per decimal digit. BCD stores the digit as is, and Excess-3 stores the digit plus 3. For decimal 45, BCD is 0100 0101 and Excess-3 is 0111 1000.

Why add 3 to every digit?

The offset makes the code self-complementing: inverting the bits of a digit gives the nine's complement of that digit. It also makes two digits whose sum is ten or more produce a natural 4-bit carry when added.

Is Excess-3 a weighted code?

No. In BCD the bit positions have fixed weights of 8, 4, 2 and 1. In Excess-3 you cannot get the digit by adding weights. You have to subtract 3 from the group's binary value.

How many groups will the result have?

One group per decimal digit of the number. Binary 11111111 is 255, which has three digits, so the result is the three groups 0101 1000 1000.

Can I convert negative binary numbers to Excess-3?

No. The input is read as an unsigned integer and a minus sign is rejected. Excess-3 itself encodes digits only, so a sign would have to be stored separately.

Related tools