File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 15080

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 8 API documentation
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46320
And what output do you get? What did you expect?
I agree. Here's the link:
subject: bit shifting example
It's not a secret anymore!