On Tue, 9 Sep 2008 07:47:08 0700 (PDT), rickman <(EMail Removed)>
wrote:
>On Sep 9, 3:33*am, Muzaffer Kal <(EMail Removed)> wrote:
>> On Mon, 8 Sep 2008 10:33:14 0700 (PDT), rickman <(EMail Removed)>
>> wrote:
>>
>> >On Sep 8, 12:58*pm, Muzaffer Kal <(EMail Removed)> wrote:
>> >> You need to sign extend to the size of the result for two's complement
>> >> multiplication work as expected for signed numbers. After the
>> >> multiplication you need to use the lower 2N bits for the result. So
>> >> 011x101 (3x3) should be treated as 000011x111101 which gives the
>> >> result 110111 6 bit result which is the expected outcome ie 9 in 6
>> >> bits.
>>
>> >If you are using signed numbers, you only need 2n1 bits to hold the
>> >result.
>>
>> >Rick
>>
>> Have you considered the most negative number multiplied by itself?
>> Unless you saturate to most positive number that result doesn't fit to
>> 2n1 bits.
>
>I think you are confused. Try the math. It fits...
>
>8 x 8 = 64 === 1000 x 1000 = 1000000
>
>or even simpler
>
>2 x 2 = 4 === 10 x 10 = 100
I know you're confused. When you square 8 you get +64 and when you
multiply 2 by itself you get +4. Continuing with the simpler case if
you have two bit two's complement numbers and you multiply the most
negative number (ie 2) by itself the result has to be a positive
number and one should be able to represent and interpret it thus. So
2 x 2 == 10 x 10 = +4 == 0100. If you drop the leading zero and
claim that the result fits into 3 bits as opposed to 4 needed then you
should interpret it as a 3 bit two's complement number which makes 100
a negative number ie 4 which is the wrong result.
The confusing issue is that two's complement numbers don't have a
symmetrical distribution in the number line. The most negative two's
complement number of any size doesn't have an equivalent in the
positive domain so one can not describe it in the same size. And when
one squares the most negative number the result doesn't fit into 2n1
but fits into 2n nicely.
