From: Ullrich von Bassewitz <*uz_at_musoftware.de*>

Date: Thu, 5 Nov 2009 19:11:18 +0100

Message-ID: <20091105181118.GA10515@trixie.musoftware.de>

Date: Thu, 5 Nov 2009 19:11:18 +0100

Message-ID: <20091105181118.GA10515@trixie.musoftware.de>

On Thu, Nov 05, 2009 at 09:38:54AM -0800, Nate Lawson wrote: > By "signed" do you mean simply that "result is negative if sign bits are > different, else positive"? Or are you trying to account for overflow > somehow? I want the operands and the result to be treated as signed, twos complement integers. The operands should be 16 bit (-32768 to 32767), the result should be 32 bit wide (-2147483648 to 2147483647). A sample operation would be -30000 * 30000 = -900000000 For a 16x16=>16 multiplication, the standard shift-and-add algorithm works for both, signed and unsigned integers. Given $FFFE * $0002 = $1FFFC if you take just the lower 16 bits of the result, it is correct for a signed multiplication: $FFFE * $0002 = $FFFC (high 16 bits dropped) -2 * 2 = -4 What I need is a multiplication that gets a correct value for the high 16 bit (the result should be $FFFFFFFC instead of $1FFFC). Currently, I'm using an unsigned 16x16=>32 multiplication with the absolute values of the operands, and adjust the sign of the result. The question is, if there is a faster method than this. Regards Uz -- Ullrich von Bassewitz uz@musoftware.de Message was sent through the cbm-hackers mailing listReceived on 2009-11-05 19:00:03

Archive generated by hypermail 2.2.0.