This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes ShiftWise operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

ShiftWise operator

Vidya Lakshman
Greenhorn

Joined: Apr 09, 2008
Posts: 11



what is the output of the above code & explain the working? Why is the code highlighted giving -ve value as the output?
Any help is highly appreciated.


Regards
Vidya
Don Redd
Ranch Hand

Joined: Jan 05, 2012
Posts: 82

1073741818 => 00111111 11111111 11111111 11111010
-24 ====> 11111111 11111111 11111111 11101000
-6 ====> 11111111 11111111 11111111 11111010

+24 ====> 00000000 00000000 00000000 00011000
+6 ====> 00000000 00000000 00000000 00000110

and you can use below URL to work out

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op3.html
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43986
    
  33
I shall take the liberty of closing this thread; read this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ShiftWise operator
 
It's not a secret anymore!