Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!postnews.google.com!34g2000pru.googlegroups.com!not-for-mail From: Sanny Newsgroups: comp.lang.java.programmer Subject: Re: Java left shift and right shift operators. Date: Tue, 26 Apr 2011 09:39:05 -0700 (PDT) Organization: http://groups.google.com Lines: 39 Message-ID: <44bbc323-c260-4169-ab2a-11b95d9e73e8@34g2000pru.googlegroups.com> References: <295e16b3-2ed8-4529-bfb0-1cc26ed93ad6@d26g2000prn.googlegroups.com> <1b558330-ae94-4e4e-9922-a9aeb63eaf37@d19g2000prh.googlegroups.com> NNTP-Posting-Host: 122.168.206.80 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1303835945 6059 127.0.0.1 (26 Apr 2011 16:39:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 26 Apr 2011 16:39:05 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 34g2000pru.googlegroups.com; posting-host=122.168.206.80; posting-account=TwCTWQgAAAC7hf6GV7aTGIk6mVGkiZ5c User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; FDM),gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3273 > >> 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=3DMath.pow(2,shiftby); > > then > > output =3D (long) N / divider; > > =A0 =A0 =A0Let me get this straight: You're worried about the inefficienc= y > of an `if' that chooses between a left or a right shift, so you plan > to eliminate the `if' by evaluating an exponential function? > > =A0 =A0 =A0ARE YOU OUT OF YOUR MIND? I didnt knew how much inefficient it is. I heard Math. (...) functions are very fast and they use Native support like assembly language so they are quite faster. Is there a "Integer" in java which is longer than 64 bits? byte: 8 bits short: ??? int: 16/32 bits long: 64 bit any 128 bit integer??? I want something that can handle more bits than long. and I am able to do bit operations on them. I have heard of BigInteger I dont know how many bits it supports. Can I use byte[] to represent a longer number and do multiplications/ divisions on them? Bye Sanny