0
\$\begingroup\$

My book provides this BCD adder with the truth table: enter image description here enter image description here

Since this is meant to add number in BCD there are combinations that aren't going to be used. My book asks to calculate how many of such combinations are there. I did:

$$[(6*9)*2+(6*6)*2]*2 = 360$$

6*9 is the valid ones times the invalid ones. 6*6 is the invalid ones. I multiply each of these by two because you can have them one way around or the other. Lastly I multiplied by 2 because the input carry can be either 1 or 0. But my book says the solution is 312. What went wrong?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ There are \$16\times 16\$ possibilities without the carry. This is doubled when you add in the carry, so there are a total of \$2\times 16\times 16=512\$ possible input permutations. Out of this, only \$2\times 10\times 10=200\$ are valid inputs -- obviously. Therefore, the answer is \$512-200=312\$. I honestly don't want to understand your own confusion here, so I didn't try to dig in enough to follow where you went wrong in your head. But it's wrong. \$\endgroup\$
    – jonk
    Dec 26, 2019 at 5:10
  • \$\begingroup\$ @jonk Looking at your answer I think I know what went wrong. I multiplied by 9 instead of 10. Thanks \$\endgroup\$ Dec 26, 2019 at 5:14
  • \$\begingroup\$ Okay. If that gets it, great! It's certainly the case that there is 0-9, or 10 valid permutations for each input. Glad it helped. Best wishes! \$\endgroup\$
    – jonk
    Dec 26, 2019 at 5:15

1 Answer 1

0
\$\begingroup\$

Like you commented, you have to multiply with 10 instead of 9. There is however another point incorrect.

You need to add the invalid ones times the invalid ones once, so

$$[(6*\color{red}{10})*2+(6*6)*\color{red}{1}]*2 = 312$$

To link your approach with Jonk's approach:
Defining variable a the number of valid BCD codes (a=10), b the number of invalid BCD codes (b=6) and a+b (therefore) the total number of codes,

Jonk's approach is $$ 2*((a+b)^2-a^2) $$ Rewriting $$ 2*((a+b)^2-a^2) = $$ $$ 2*(a^2+2ab+b^2-a^2) = $$ $$2*( 2ab + b^2 ) $$ which is your approach.

\$\endgroup\$
2
  • \$\begingroup\$ I think my approach is way easier to understand and lots less likely to go wrong, because it avoids getting mired in unnecessary detail that makes it more likely to make a mistake in the process. But what do I know? \$\endgroup\$
    – jonk
    Dec 27, 2019 at 2:19
  • \$\begingroup\$ @jonk I also think you're way is absolute easier. But OP's approach is valid too. It was by writing out your approach I found another error in OP's elaboration. Regarding your last question: from what I've seen a lot! \$\endgroup\$
    – Huisman
    Dec 27, 2019 at 7:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.