Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Java left shift and right shift operators. Date: Tue, 26 Apr 2011 07:34:27 -0400 Organization: A noiseless patient Spider Lines: 19 Message-ID: References: <295e16b3-2ed8-4529-bfb0-1cc26ed93ad6@d26g2000prn.googlegroups.com> <1b558330-ae94-4e4e-9922-a9aeb63eaf37@d19g2000prh.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 26 Apr 2011 11:34:32 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="KiwfXDyOjqGhZBXcfNnZBg"; logging-data="6734"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18VWgU/IHyzHpE5IVjxH3wF" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: <1b558330-ae94-4e4e-9922-a9aeb63eaf37@d19g2000prh.googlegroups.com> Cancel-Lock: sha1:du3uXu64FTui/ISzktfGvMrUolI= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3258 On 4/26/2011 5:04 AM, Sanny wrote: >> Is there any way to avoid the if condition and do right shift and left >> shift using operators depending on shiftby is +ve or -ve? > > I used below technique but it gives error. > > divider=Math.pow(2,shiftby); > then > output = (long) N / divider; Let me get this straight: You're worried about the inefficiency of an `if' that chooses between a left or a right shift, so you plan to eliminate the `if' by evaluating an exponential function? ARE YOU OUT OF YOUR MIND? -- Eric Sosman esosman@ieee-dot-org.invalid