Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: How do I multiply positive and negative numbers? (in n's complement)

  1. Jul 12, 2012 #1
    1. The problem statement, all variables and given/known data
    I need to understand how signed multiplication is done in 2's to 10's complement.

    2. Relevant equations
    The complement D' of a number D with m digits in base r is rm - D.
    So, the complement of 010 in binary (2 in dec) is 1000 - 010 = 110 (-2, but 6 if it were unsigned). We add a leading 0 because there is no such thing as positive 2 in 2-bit 2's complement.
    The complement of 20 in ternary (6) is 10 (3) because they sum to 100 (9, or 32).

    3. The attempt at a solution
    I understand how multiplication works in binary, but I'm having trouble figuring out how it extend to higher bases. For example, 12 * 22 (5 * -1) in three's complement. I know that it is the complement of 12, which is 11, but I have no idea how to work this out as a multiplication problem. The particular homework problem I'm being asked to solve is 202 * 121 (-7 * -11), but obviously I'm not really looking for an answer here.
  2. jcsd
  3. Jul 15, 2012 #2
    Okay, never mind, I figured out how multiplication works.
    But now I have another question.
    I know that in 4 bit unsigned binary, the number places have weights of 23 22 21 20 just like in decimal with 103 102 101 100. However, in two's complement, the weights are -23 22 21 20, which is why 1111 = -23 22 21 20 = -8 + 4 + 3 + 1 = -1. But that isn't the whole story. We aren't multiplying -23 by 1, we are multiplying it by the COMPLEMENT of 1, which is 10 - 1, or 1. So nothing changed.
    But in a negative three's complement number, we can have either a 1 or a 2 in that "sign bit", which means that that final complementation does matter because 10 - 1 = 2 and 10 - 2 = 1.
    My question is, why do we have to complement the most significant bit to find out what we use to multiply the weight of that position?

    edit: Come to think of it, would this be better in the number theory section? But this is homework and it is for a computer science class...
  4. Jul 15, 2012 #3


    User Avatar

    How did you come up with the answer?

    I can see that positive multiplication in three's complement is just plain multiplication without complementing the answers and without using sign extension, but can't seem to figure out any type of negative multiplication (- * +, + * -, - * -).
  5. Jul 16, 2012 #4
    It ties a bit into my second post. Our usual method of multiplication assumes that digits are assigned a specific weight based on their position. As you probably know, when we move our partial product computations to the left while doing our nostalgic primary-school multiplication algorithm, we are actually multiplying by a power of 10. It turns out that complement number systems can be looked at like our usual position based number system, except that final weight is negative. With that in mind, all you need to do is find the complement of that number to get its magnitude which is what you're supposed to multiply your multiplicand with. The problem is that this only works for negative numbers in three's complement, and numbers with a 1 in their "sign bit" seem to be arbitrarily positive or negative.

    Also, I see that you happen to have one post. Please don't tell me that this topic also happens to be a critical part of a class you are taking, and your professor also happens to expect you to have innate knowledge of race conditions inside buggy circuit simulation programs.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook