Skip to main content

39 to Gray/Excess-3 and 2's complement addition

Short answer

39 in Gray: binary 100111, Gray = 1 then XOR adjacent: 1,0,1,0,0 → 110100. Excess-3: 3→0110, 9→1100 → 0110 1100. (-28+17) in 8-bit 2's complement: -28 = 11100100, +17 = 00010001, sum = 11110101, which is -11.

Convert decimal 39 into Gray code and Excess-3 code. Use 2's complement method to perform the following addition (-28+17)₁₀.

Decimal 39 to Gray code

First convert to binary by repeated division by 2:

DivisionQuotientRemainder
39 ÷ 2191
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201

Reading upwards: (39)10=(100111)2(39)_{10} = (100111)_2.

Binary to Gray (keep MSB, then XOR adjacent bits):

 Binary : 1   0   0   1   1   1
          |  / \ / \ / \ / \ /
 Gray   : 1   1   0   1   0   0

G=1, 1⊕0=1, 0⊕0=0, 0⊕1=1, 1⊕1=0, 1⊕1=0G = 1,\ 1\oplus0=1,\ 0\oplus0=0,\ 0\oplus1=1,\ 1\oplus1=0,\ 1\oplus1=0

Answer: (39)10=(110100)Gray(39)_{10} = (110100)_{Gray}

Decimal 39 to Excess-3

Add 3 to each digit: 3 + 3 = 6 → 0110; 9 + 3 = 12 → 1100.

Answer: (39)10=(0110 1100)XS−3(39)_{10} = (0110\ 1100)_{XS-3}

(−28) + (17) using 2's complement (8-bit)

  • +28=0001 1100+28 = 0001\ 1100
  • 1's complement: 1110 00111110\ 0011; add 1 → −28=1110 0100-28 = 1110\ 0100
  • +17=0001 0001+17 = 0001\ 0001
    1110 0100   (-28)
  + 0001 0001   (+17)
  -----------
    1111 0101   no end carry

No end carry, so the result is negative and in 2's complement form. Take the 2's complement to find its magnitude: 0000 1010+1=0000 1011=110000\ 1010 + 1 = 0000\ 1011 = 11.

Answer: (−28)+17=1111 01012=(−11)10(-28) + 17 = 1111\ 0101_2 = (-11)_{10}

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 1 questions →