Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site calgary.UUCP Path: utzoo!utcsri!ubc-vision!alberta!calgary!radford From: radford@calgary.UUCP (Radford Neal) Newsgroups: net.arch Subject: Re: Right shift vs. divide (change divide!) Message-ID: <49@calgary.UUCP> Date: Fri, 17-Jan-86 03:07:39 EST Article-I.D.: calgary.49 Posted: Fri Jan 17 03:07:39 1986 Date-Received: Fri, 17-Jan-86 12:15:26 EST References: <124000005@ima.UUCP> <4772@alice.UUCP> <1016@turtlevax.UUCP>, <32@calgary.UUCP> <345@mcgill-vision.UUCP> Organization: University of Calgary, Calgary, Alberta Lines: 34 > Only reason I can see for a mathematician -- for anyone -- to want > it to work this way is that then x-(y*(x/y)) is always >=0. > Unfortunately, doing this breaks other nice properties, in particular > that x/y equals -((-x)/y). It therefore means that hardware can't > handle negative numbers by simply negating before and after the > operation. I don't see why you aren't satisfied with -3/2=-1 and > -3%2=-1. You still have that x=(x%y)+(y*(x/y)), which is really all > mathematicians demand, as far as I know (flame retardant: my knowledge > of number theory is limited to undergrad level). In applications where number theory is relevant there is a powerful demand that x%y = (x+y)%y which isn't true with truncate toward zero division. > What do you want done with -3/-2 or 3/-2? Beets me. I'm rather confused as to when people actually use negative divisors and what should be done about them. But as a first cut I might go for: 7/3 = 2 7%3 = 1 -7/3 = -3 -7%3 = 2 7/-3 = -2 7%-3 = 1 -7/-3 = 3 -7%-3 = 2 This preserves the properties that x = (x/y)*y + x%y and 0 <= x%y < |y| Radford Neal University of Calgary