Multiplying 2 signed numbers => 2 sign bits ??

Status
Not open for further replies.

omara007

Advanced Member level 4
Joined
Jan 6, 2003
Messages
1,237
Helped
50
Reputation
102
Reaction score
16
Trophy points
1,318
Location
Cairo/Egypt
Activity points
9,716
signed multiply

Hi folks

If I'm multiplying 2 signed numbers, say each is represented as 16-bit 2's complement binary vector. Will the 32-bit result contain 2 sign bits or 1 ?
 

2009 with 2 numbers and 2 signs

The 32-bit result must contain 1 sign bit.
Look for the following Atmel application note:
AVR201: Using the AVR Hardware multiplier
I think this note may help you.
 

c fractional signed multiply

svicent said:
The 32-bit result must contain 1 sign bit.
Look for the following Atmel application note:
AVR201: Using the AVR Hardware multiplier
I think this note may help you.


Can you give, even simple, example on a result of multiplying 2 two's-complement number with the 2 MSBs of the results not the same ?
 

2 sign bits for fractional multiplication

Yes, the product of the largest negative numbers, e. g. -128*-128 (0x80*0x80) in case of signed 8*8.

P.S.: Strictly spoken, 2's complement numbers have no sign bit, so they also can't have two. I understand, that you're wondering if the 16*16 signed multiply result has redundant bits. As you can see from my example, it hasn't. But it nearly has. If you implement saturation logic, you can replace 0x80*0x80 = 0x4000 by 0x3FFF. Then you can omit one "sign" bit, respectively perform an arithmetic left shift of the result. This way, you get a correct scaled fractional signed multiply, as discussed in the said Atmel application note.
 

avr multiply 2 vectors

This reply is to inform the board/forum that my problem was solved and the topic/thread can be closed.

Effectively there is one case in which the multiplication of 2 signed numbers (of the same size) won't result in 2 sign bits. This case is when you multiply the largest negative numbers (that can be expressed in the given number of bits). Other than this case, there are always 2 sign bits in the result.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…