Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site mmintl.UUCP Path: utzoo!linus!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP (Frank Adams) Newsgroups: net.lang.c Subject: Re: Right shift vs. divide Message-ID: <937@mmintl.UUCP> Date: Fri, 27-Dec-85 00:50:26 EST Article-I.D.: mmintl.937 Posted: Fri Dec 27 00:50:26 1985 Date-Received: Sat, 28-Dec-85 13:15:58 EST References: <974@brl-tgr.ARPA> Reply-To: franka@mmintl.UUCP (Frank Adams) Organization: Multimate International, E. Hartford, CT Lines: 17 In article <974@brl-tgr.ARPA> Schauble@mit-multics.arpa (Paul Schauble) writes: >This optimization only works >if the numbers are known to be non-negative. A Pascal compiler may make >this optimization, becausethe programmer may specify the range for >variables, but not C. And you were doing so well up to this point! :-) Of course a C compiler can make this optimization, because the variables may be declared unsigned. By the way, the FORTRAN compiler for the DEC-10 would process an integer divide by two by checking the sign, incrementing if negative, and then doing a right shift. Since the divide took special setup (the single vs double length operands problem), this didn't necessarily even take more space than a divide instruction. Frank Adams ihpn4!philabs!pwa-b!mmintl!franka Multimate International 52 Oakland Ave North E. Hartford, CT 06108