The problem that I'm having trouble in understanding is how the addition of two decimal numbers such as 17 + 4 can be represented using the weighted BCD CODE, [7 4 -2 -1] and binary addition techniques.

From what I have understood when doing BCD Addition using the [8 4 2 1] coding is that when the sum of a 4-bit result is <9 then the result is valid. When there is a carry from a sum into the next group of bits then we need to add 6 to the code in order to put it into 8421 code since BCD does not allow codes 10-15. The other case is when the 4-bit result is >9 then we will also add 6 to the bit to return it to the [8 4 2 1] format.

When trying this same logic on the sum of 17 + 4 = 21 I was not able to obtain the representation of 21 using the given coding. The answer should be:

0110 0111 = 21

My logic used for the question was the following:

Working out used to try to solve 17 + 4 using the given weighted BCD code

I have read some further material related to the addition of BCD codes but closest I found was an example using Aiken-Code, [2421] coding.

Aiken-Code addition example

  • \$\begingroup\$ Are you just thinking about this stuff, out loud? Or is there classwork behind this? Take a look at adding decimal 1 to decimal 1. The code is 0000 0111. So add that up using simple binary addition and you get 0000 1110. Both digits are valid. However, it now says the answer is 9. Which doesn't make sense. Can you see the problem? Do you see how to fix up the approach? \$\endgroup\$ – jonk May 9 '19 at 19:34
  • \$\begingroup\$ @jonk So I see that we would get 9 but the answer should be two. Does that mean that I would take the difference of 9 and 2 and then add the equivalent code to the first group? And I write questions on my google spreadsheet after studying something and this was something that I got wrong after going through some of the questions I made. \$\endgroup\$ – Clive E May 9 '19 at 19:44
  • \$\begingroup\$ Do you know what a carry-out from the -2 does? It carries into +4. A carry out of -1 does make sense when it carries into -2. But what about a carry out of +4? It's 8, right? But it carries into +7, instead. Another issue. What about the carry-out of +7? (Should be +14, but what is it?) \$\endgroup\$ – jonk May 9 '19 at 19:51
  • \$\begingroup\$ @jonk I'm just trying to comprehend what you are saying. So when I did the sum of 1 and 1 we got nine and was meant to get 2. To get from 9 to 2 I added the equivalent BCD code of 7 to nine which resulted in the first group being 2 after and the second group was an invalid character so I presumed we disregarded it. Was I wrong to do this? \$\endgroup\$ – Clive E May 9 '19 at 20:00
  • \$\begingroup\$ @jonk And in regards to the +14 this is an invalid code but can be split using 1 as 0111 and 4 as 0100, then we would add this. Would this be the correct approach? \$\endgroup\$ – Clive E May 9 '19 at 20:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.