This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes bit shifting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "bit shifting" Watch "bit shifting" New topic
Author

bit shifting

Francis Palattao
Ranch Hand

Joined: Sep 22, 2004
Posts: 91
I thought that using >>> always results in a positive.

For this example it doesn't

byte b = -13;
b >>>= 1;
System.out.println(b);

Answer is -7


SCJP 1.4 <br />SCWCD 1.4 (preparing)<br />SCBCD 1.3 (coming soon)
Joe Borderi
Ranch Hand

Joined: Oct 23, 2004
Posts: 151
Try running this code:
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
b is a byte, but the >>>= works on ints, so b is promoted to an int for the operation, then the result is implicitly narrowed back to a byte:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: bit shifting
 
Similar Threads
Exception Inheritance Hierarchy
iterating ArrayList in forEach
Whats the Output. of this.....?
Need help on the following question?
test