Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: Division With Shifts Message-ID: <2711@umcp-cs.UUCP> Date: Thu, 9-Jan-86 23:01:42 EST Article-I.D.: umcp-cs.2711 Posted: Thu Jan 9 23:01:42 1986 Date-Received: Sat, 11-Jan-86 06:15:45 EST References: <1395@brl-tgr.ARPA> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 12 I think everyone agrees that for nonnegative integers, (i >> 1) == (i / 2). So let us ignore those. For negative integers, (i >> 1) tends to round towards -infinity instead of towards zero. To fix this all you need to do is add one before shifting. I was going to show why, but it hardly seems worth the effort. It just works. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu