Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!ark From: ark@alice.UucP (Andrew Koenig) Newsgroups: net.lang.c Subject: Re: Right shift vs. divide Message-ID: <4734@alice.UUCP> Date: Mon, 23-Dec-85 11:03:42 EST Article-I.D.: alice.4734 Posted: Mon Dec 23 11:03:42 1985 Date-Received: Wed, 25-Dec-85 01:11:33 EST References: <974@brl-tgr.ARPA> Organization: Bell Labs, Murray Hill Lines: 11 > Anyone still think they're the same thing? 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. Moral: a C compiler can substitute a right shift for a divide by a constant power of two if and only if the LHS of the expression is an unsigned integer type. By the way, a right shift of a signed quanitity is not required to be an arithmetic shift.