Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Multiplying 2 signed numbers => 2 sign bits ??

Status
Not open for further replies.

omara007

Advanced Member level 4
Joined
Jan 6, 2003
Messages
1,238
Helped
50
Reputation
102
Reaction score
16
Trophy points
1,318
Location
Cairo/Egypt
Activity points
9,747
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 ?
 

svicent

Full Member level 6
Joined
Jul 11, 2001
Messages
322
Helped
33
Reputation
64
Reaction score
7
Trophy points
1,298
Activity points
2,293
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.
 

omara007

Advanced Member level 4
Joined
Jan 6, 2003
Messages
1,238
Helped
50
Reputation
102
Reaction score
16
Trophy points
1,318
Location
Cairo/Egypt
Activity points
9,747
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 ?
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
48,369
Helped
14,245
Reputation
28,751
Reaction score
12,931
Trophy points
1,393
Location
Bochum, Germany
Activity points
279,978
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.
 

omara007

Advanced Member level 4
Joined
Jan 6, 2003
Messages
1,238
Helped
50
Reputation
102
Reaction score
16
Trophy points
1,318
Location
Cairo/Egypt
Activity points
9,747
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top