Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!linus!philabs!cmcl2!seismo!brl-tgr!tgr!bader (Miles Bader)@b.psy.cmu.edu From: bader@b.psy.cmu.edu (Miles Bader) Newsgroups: net.lang.c Subject: Divisions with shifts Message-ID: <1365@brl-tgr.ARPA> Date: Wed, 8-Jan-86 23:10:25 EST Article-I.D.: brl-tgr.1365 Posted: Wed Jan 8 23:10:25 1986 Date-Received: Sat, 11-Jan-86 05:41:07 EST Sender: news@brl-tgr.ARPA Lines: 12 Just shifting using an arithmetic shift may give the wrong answer, but you could correct the rounding and still get much faster execution like: shiftRightArithmetic register branchIfPositive label increment register label: so -23/2 = -23>>1 + 1 = 11101001>>2 + 1 = 11110100 + 1 = 11110101 = -11 which is the right answer... -Miles