Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site mips.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!decwrl!glacier!mips!hansen From: hansen@mips.UUCP (Craig Hansen) Newsgroups: net.arch Subject: Re: Right shift vs. divide (change divide!) Message-ID: <285@mips.UUCP> Date: Fri, 10-Jan-86 21:24:48 EST Article-I.D.: mips.285 Posted: Fri Jan 10 21:24:48 1986 Date-Received: Mon, 13-Jan-86 08:04:34 EST References: <124000005@ima.UUCP> <4772@alice.UUCP> <1016@turtlevax.UUCP> <32@calgary.UUCP> Organization: MIPS Computer Systems, Mountain View, CA Lines: 34 > Rather than get rid of the arithmetic right shift, one could instead > change the divide instruction so it does what mathematicians have > always thought division meant. So now we've seen every possible solution: ignore it, fix arithmetic right shift, and now fix divide! There are indeed two consistent definitions of divide, both of which satisfy the relation: x = (x / y) * y + (x % y) The two definitions basically amount to evaluating x/y by (1) rounding toward -infinity and (2) rounding toward zero. Each have their own advantages: a) 1) the sign of the remainder = the sign of the divisor 2) the sign of the remainder = the sign of the dividend b) 1) x >= (x/y)*y 2) |x| >= |(x/y)*y| (2) is the most commonly implemented form of divide. (1) looks like the most commonly implemented arithmetic right shift. (2) is useful for signal processing applications because of the (b) property. (1) is useful for applications involving residue arithmetic because of the (a) property, i.e. the remainder is a proper residue. Ideally, a machine would have both (or neither). Craig Hansen MIPS Computer Systems