🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #21921

Re: Integer Multiply/Divide

#21921
From: Norbert Schlenker
Date: Wed, 03 Jan 1990 05:34
12 lines
1204 bytes
In article <9193@cbmvax.commodore.com> jesup@cbmvax.commodore.com (Randell Jesup) writes:
>In article <4057@brazos.Rice.edu> preston@titan.rice.edu (Preston Briggs) writes:
>>Division is slightly more complex, due to sign handling.
>>For most languages, it isn't safe to replace a divide by 2^N
>>with a shift right (doesn't work for negative numbers).
>
>	Easy solution: x/2^n = (x >> n) + (x & 1 & (bit 31 of x)).  Of course,
>the >> operation must be "arithmetic" and not "logical" (i.e. sign-extending).

This doesn't work.  Consider -10/2^3, which results in -2.

>Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
Technical Details
Message-ID: <22705@princeton.Princeton.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!rochester!udel!princeton!notecnirp!nfs
References: <84768@linus.UUCP> <4057@brazos.Rice.edu> <9193@cbmvax.commodore.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!pt.cs.cmu.edu!rochester!udel!princeton!notecnirp!nfs
From: nfs@notecnirp.Princeton.EDU (Norbert Schlenker)
Newsgroups: comp.arch
Subject: Re: Integer Multiply/Divide
Message-ID: <22705@princeton.Princeton.EDU>
Date: 3 Jan 90 05:34:01 GMT
References: <84768@linus.UUCP> <4057@brazos.Rice.edu> <9193@cbmvax.commodore.com>
Sender: news@princeton.Princeton.EDU
Reply-To: nfs@notecnirp.UUCP (Norbert Schlenker)
Organization: Dept. of Computer Science, Princeton University
Lines: 12