1

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

Huisman
  • 10,594
  • 2
  • 19
  • 40
Clive E
  • 11
  • 1
  • 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? – jonk May 09 '19 at 19:34
  • @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. – Clive E May 09 '19 at 19:44
  • 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?) – jonk May 09 '19 at 19:51
  • @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? – Clive E May 09 '19 at 20:00
  • @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? – Clive E May 09 '19 at 20:05
  • An 8,4,−2,−1 code is self-complementing and that fact can be useful because complementing the code yields the 9s complement of the digit. It's also easier to set up for the adders. But what's the goal for the 7,4,-2,-1 code? What made you pick this particular one? (I think there are two different codes for +4, too.) – jonk May 09 '19 at 20:17
  • @jonk So what you are saying is that when I have summed the 17 and 4 and obtained [ 0111 1100 ] I should take the complement of it? I was just thinking too that I could take the complement of 1100 which is 0011 and then plus 4 to this which gives 0111 and I would get the first digit of 1? – Clive E May 09 '19 at 20:43
  • Actually, I'm mostly interested in why you want to make all this work correctly. I'm asking questions and suggesting thoughts to consider. But not yet saying much, because I'm not sure the purpose here. Is this part of a class? If so, what have they told you about performing such additions and "fix-ups?" – jonk May 09 '19 at 20:44
  • Well it was a past topic, that was done in class, a related problem that I did really well in was creating a 7-segment display calculator using an unweighted code and then finding out what would display if there was an error. An idea I have in mind is to try and design a 7 4 -2 -1 to 8421 calculator. – Clive E May 09 '19 at 20:53

0 Answers0