Shift operators

import java.util.*;
class Shift
{
    public static void main(String args[])
        {
            int a;
            float b1,b2;
            Scanner sc = new Scanner(System.in);
            System.out.println("Enter a number:");
            a=sc.nextInt();
            b1=a<<3;
            System.out.println("After shifting three bits left:    \na="+b1);
            b2=a>>3;
            System.out.println("After shifting three bits  right:\na="+b2);
        }
}

No comments :

Post a Comment