# B Complement Multiplication

Hello,

since the exam is tomorrow and I´m really confused, I hope it is okay to ask a question on sunday.

I  practised B-Complement Multiplication with the numbers <7306>12 and <A0A2>12. I got something different than the teaching tool and I am really confused about two parts of the grid: 1. the red rectangle: I compute 0 * (10-12) since A is the MSB of the second number which is still 0 obviously. Then I add B from the line above and 0 from the digit on the right. I get obviously B, but why is there still a -1 carry since 0 is not negative?

2. the green rectangle: I compute (7-12)*(10-12) = 10 and then I add 11 from the line above and 0 as the carry of the right digit. I end up getting 21 which is 1 * 12 R9 so I understand the 9 but with 1 as a carry. What is wrong with my solution?

I practised some more and faced another example which confused me a lot. I might just have a wrong way of solving those B-Complement Multiplication but until today I did not face those problems.

<7A18>14 * <9880>14 1. the red rectangle: I computed A * (9-14) = - 50. Adding both carries I get -50 + 13 + 6 and end up with -31. Now I add 3*14 to get +B and -3 as a carry because I added 14 3 times. Where is my fault?

2. the green rectangle: I computed (7-14)*(9-14) = 35. Adding both carries I get35 + 10 - 4 = 41. 41/14 is 2 RD so I understand the D but I don´t understand why the carry is 1 instead of 2.

Thank you very much and again sorry for asking a quesion on sunday!

Best regards

I ran the program IntMultCRACRA with your inputs <7306>12 * <A0A2>12 and got the following partial products that have to be summed up to obtain the shown product:

```                B   0   5   1   0   // pp[4..0]
B   B   0   5   1       // pp[4..0]
B   6   1   6   B           // pp[4..0]
0   9   1   A   8               // pp[4..0]
-------------------------------
0   9   1   A   8   B   1   0   // p[7..0]    ```

Computation of the partial products:

```    <7306>12 * A = <B,0,5,1,0>12
<7306>12 * 0 + <B,0,5,1>12 = <B,B,0,5,1>12
<7306>12 * A + <B,B,0,5>12 = <B,6,1,6,B>12
<7306>12 * 2 + <B,6,1,6>12 = <0,9,1,A,8>12
```

About the red rectangle: You have to apply function alpha when you reach the most significant digits, i.e., in your red rectangle where we have i=1 and j=3=N-1, you have to compute the following

```    sm = xin * yin + pin + cin
= x * alpha(y) + alpha(pp) + cp
= 0 * alpha(7) + alpha(B) + 0
= 0 * alpha(7) + alpha(B)
= (11<(12/2) ? +x : +11-12)
= +11-12
= -1
```

and with this, you obtain

```    cp = -1
pp = 11
pp = gamma(-1) = 11
```

About the green rectangle: Here we have i=3=M-1 and j=3=N-1, and we therefore compute

```    sm = xin * yin + pin + cin
= alpha(x) * alpha(y) + alpha(pp) + cp
= alpha(7) * alpha(A) + alpha(B) + 0
= alpha(7) * alpha(A) + alpha(B) + 0
= -5 * -2 + -1 + 0
= 10 + -1 + 0
= 9
```

and with this, you obtain

```    cp = 0
pp = 9
pp = gamma(0) = 0
```

recall

```    alpha(x) = (x<(Base/2) ? +x : +x-Base);
gamma(y) = (y<0 ? y+Base : y);```

Does this help?

by (138k points)
selected by
Okay I figured out that I have to apply alpha not just on the digits themselves but also on the carries as long as the carries are the MSB from the line above. Am I right?

That at least works with my method of computing B-Complement Multiplication now and I get the correct results. Thank you very much for your time and effort.
I know that these algorithms appear at first trivial, and then very complicated when you look at some details. It is therefore really really needed to do some example computations to check these steps. That is done best by strictly following what's written in the code, and later on thinking why that is so.