This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes bit shifting example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "bit shifting example" Watch "bit shifting example" New topic

bit shifting example

Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
I was looking at following example from link

public class Shift2{
static int i=2;
public static void main(String argv[]){
System.out.println(32 % 32);
System.out.println( 3 >>> 32);
I clearly did not understood output.
I have not understood concepts behind >>>, >>,<<<,<<

Any ideas, resources,sample code,links, highly appreciated. thanks in advance.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884

Have a look at the tutorials: Bitwise and Bit Shift Operators.

Note: The <<< operator does not exist. Only: >>, >>> and <<.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 36599
And what output do you get? What did you expect?
I agree. Here's the link:
subject: bit shifting example
Similar Threads
Thinking in java Package excercise
Exception interview question
Shift Operators
Having trouble with passing parameters to methods
CHEECKY but i need help FAST please!