Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Java left shift and right shift operators. Date: Tue, 26 Apr 2011 15:02:03 -0400 Organization: albasani.net Lines: 42 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=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net liq/ygAUiRmKd/X3HvnDmpuQds7mYNpToGAzid/cBs17h3bxcCJXsRd9TIn9GVdlaM8nQjI60aktxnUwXYyRDPQ1Gg21EWduaIU/bkL0tv7h/e41Kri/qiLJsf8eHlR5 NNTP-Posting-Date: Tue, 26 Apr 2011 19:01:56 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="ia+gI/oLeccRyWywTECkd4mi/2r7ZUns7FJiR/buGBuvxF1mQXp3TeSuFX4myR77/CjvLbvyIjsr1f2EBwZroYxNV+r8vGYHZitk0FsBiwQPfPdDl6o2yW2+0xLQ/eup"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8 In-Reply-To: Cancel-Lock: sha1:cwzoIyRcOcGjXJ6nva4lhhkuhYQ= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3281 Sanny, please attribute your citations. Sanny wrote: >>> Doesn't matter, the Java operator *is* defined for negative values. See? You didn't write that. Sanny wrote: > Lew wrote: >>> Doesn't matter, the Java operator *is* defined for negative values. >>> So the solution to Sanny's problem is: >> >>> output = n>> shiftBy; >> >> OK, that is a trick answer because it's wrong. True, the shift operator is >> defined for negative shift values, but those get masked to positive shift >> values regardless and don't give the OP's desired result. Sanny wrote: > I did not get any error when using it but the answer was "0" when I > used negative shifts. What was the shift value you used? What were the lower five bits of the right operand (if the left operand was 'int') or six bits (if the left operand was 'long')? > Maximum value a integer can hold is 64 bit in long variable. I want a > even larger number. Can I create a larger number which allows right- > shifts and left shifts? by multiplication/ division? RTFM. RTFM. RTFM. RTFM. RTFM. RTFM. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg