How to subtract BCD numbers?

31k Views Asked by At

For example: $1001 0011 - 0101 0110$

I am unsure what to do. Is there some correction factor just like with BCD addition?

1

There are 1 best solutions below

2
On BEST ANSWER

In binary subtraction, we find the 2's complement of operand $b$ by inverting all bits and adding a $1$. When adding this to $a$ you have performed $a-b$. In BCD we have to find the 10's complement. This is done by subtracting 9 from each decimal digit (a 4 bit binary number) and adding a $1$. Now, using ordinary BCD addition rules we add the two numbers.

Example:

10's complement of 0101 0110 is 0100 0100 (subtracted 9 from each 4 bit segment and added a $1$ to the last one. Notice that this could overflow when finding the 10's complement of $0000$. You would have to correct the BCD number.).

Now adding 1001 0011 and 0100 0100:

$1001 0011 + 0100 0100=1101 0111$

Correction is done when a digit acceeds the value 9 ($1001$ in BCD). The first digit is correct. The second digit is invalid. To correct it we add 6 ($0110$ in BCD). $1101+0110=0011$ (ignore overflow).

So:

$1101 0111$ becomes $0011 0111$

Therefore:

$1001 0011 - 0101 0110=0011 0111$

Let's check if this is correct:

$1001 0011=93$
$0101 0110=56$

$93-56=37=0011 0111$