Davy said:

Hi all,

I have 2's Complement digit range from negtive to positive. How to

multiply it with a constant?

Now, I have to turn 2's complement to signed-digit format and do

shift-addition/multiplication.

And there is a big problem confused me a long time:

Is there any method have the merits from signed-digit(easy to multiply)

and 2's complement(easy to add)?

I'm assuming doing this on platforms without a hardware multiplier or a

multiply instruction. Otherwise multiplying with a constant is the same

as multiplying with a variable.

In which case, I don't get it. 2's complement is as easy to multiply as

it is to add. There's no need to convert it to signed digit first.

Lets look at some examples of 2's complement multiplication of negative

numbers, we'll stick to 8 bits to make it short:

-1 * 2 = -2

11111111 (-1, shift left by 1 to multiply by 2)

11111110 (equals -2)

-5 * 4 = -20

11111011 (-5 shift left by 2 to multiply by 4)

11101100 (equals -20)

-3 * 5 = -15

11111101 (-3 shift left by 2 to multiply by 4)

11110100 (equals -12 add -3)

11110001 (equals -15)

In none of the examples above do I need to convert to signed digit. If

multiplying by a negative constant, then simply use the positive

version of the constant and 2's complement the variable before

multiplying (in effect multiplying it by -1):

1 * -2 = -2

00000001 (1, 2's complement to multiply by -1)

11111111 (-1, shift left to multiply by 2)

11111110 (equals -2)

-1 * -2 = 2

11111111 (-1, 2's complement to multiply by -1)

00000001 (1, shift left to multiply by 2)

00000010 (equals 2)

I don't get what you're complaining about.