Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site myrias.UUCP Path: utzoo!utcsri!ubc-vision!alberta!myrias!cmt From: cmt@myrias.UUCP (Chris Thomson) Newsgroups: net.lang.c Subject: Re: Two Birds with One Stone Message-ID: <199@myrias.UUCP> Date: Tue, 24-Dec-85 20:22:24 EST Article-I.D.: myrias.199 Posted: Tue Dec 24 20:22:24 1985 Date-Received: Tue, 24-Dec-85 22:24:41 EST References: <874@dataioDataio.UUCP> <864@kuling.UUCP> Organization: Myrias Research, Edmonton Lines: 8 > >Almost but not quite true. A compiler CANNOT normally replace a divide > >by a right-shift if it is an integer divide. This is because a right > >shift of a negative integer is not the same as a divide. > > However most useable processors provide arithmetic shifts which will give > the right result even if it is a signed divide. The first is correct, the second is WRONG. -1/2 is 0 not -1.