2
$\begingroup$

I'm trying to understand the professor who wrote about Q2-fixed-point number 1.01 and 1.11 which should be multiplied. I don't understand anything.

Multiply the Q2-fixed-point number 1.01 and 1.11 and give the result as a Q4-number. Answer:

1.01 * 1.10
-----------
 0.01    (2-komplement of 1.01)
   0
 1.1111
-----------
10.0011 (sign extension)
 0.0011

The result of the multiplication is a positive number. Thus 1.01 is negated by adding the boolean complement to 1. The final result is 0.011. This can be verified using decimal multiplication. The Q2-number 1.01 is -0.75 in decimal base 10 and the Q2-number 1.10 is -0.5 in decimal. Thus the result is 0.375 which is represented as the Q4-number 0.11.

I don't understand the above at all. I understand that 1.01 is -0.75 and that 1.10 is -0.5_10 in decimal but why use 1.10, where does it come from? Why use the 2-complement in the first place? What does the calculation mean? What does the zero mean? It is the most confusing "answer" I've ever seen.

$\endgroup$
0

1 Answer 1

3
$\begingroup$

There are errors in the presented answer. Here's the same but corrected and rewritten a bit:

 1.01 * 1.11
--------------
 carry: 1 1
        1.1111  (shift right 1.11 with sign extension)
        0.000
      + 0.01    (2's complement of 1.11)
--------------
      = 0.0011

Here, 2's complement means negation, which is done by flipping each bit and adding one least significant bit valued 1. In multiplication of signed binary numbers, if the first multiplicand (the one that is not shifted) is negative, the correct result is obtained by doing subtraction in place of the last addition by the second multiplicand, and that's the + 0.01 line. It's a binary trick that is equivalent to actually dragging along all the sign extensions, which leads to large values in the carry and more steps than necessary:

 1.01 * 1.11
--------------
 carry: 2 1
        1.1111  (shift right 1.11 with sign extension)
        0.000
        1.11
        1.1     (sign extension of the multiplicand 1.01 is ...111.01)
      + 1.
--------------
      = 0.0011

There is no need to have two binary decimals before . in the result.

The subtraction trick can be tested with different values and it passes all the tests:

              carry:             1               1
second multiplicand: 000 001 010 011 100 101 110 111 
                     00  01  10  11  00  01  10  11
                   + 0   1   0   1   0   1   0   1
----------------------------------------------------
                   = 000 111 110 101 100 011 010 001
     2's complement: 000 111 110 101 100 011 010 001
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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