aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes bitwise operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "bitwise operator" Watch "bitwise operator" New topic
Author

bitwise operator

prafulla shrikhande
Greenhorn

Joined: Mar 12, 2003
Posts: 4
this was a good one on bitwise operators -

i = 1;

i <<= 31;
i >>= 31;
i >>= 1;

whats the value of i?
Pedro Ivo Dantas
Greenhorn

Joined: Sep 03, 2004
Posts: 10
It depends on the type of the variable i. If it is a int, as I suppose was your intention, then the resulting value will be -1 (11111...1111). If it is a long, then the result will be 0.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: bitwise operator
 
Similar Threads
bitwise operations on negative numbers
>> operator question
shift Operators
shift
shift question