Write a program to perform different bit wise operations

class third
{
public static void main(String args[])
{
int no1=Integer.parseInt(args[0]);
int no2=Integer.parseInt(args[1]);
int and,or,exor,not,Lshift,Rshift;

and = no1&no2;
or = no1|no2;
exor = no1^no2;
Lshift = no1<<2;
Rshift = no1>>2;

System.out.println("this operation beetween "+no1+" and "+no2+"\n");
System.out.println("binary is =>\t"+toBinaryString(no1)+ " and " +toBinaryString(no2));
System.out.println("\n1. AND operation =>\t"+and);
System.out.println("\n2. OR operation =>\t"+or);
System.out.println("\n3. NOT operation =>\t"+ ~no1);
System.out.println("\n4. EXOR operation =>\t"+exor);
System.out.println("\n5.Lshift operation=>\t"+Lshift);
System.out.println("\n6.Rshift operation=>\t"+Rshift);
System.out.println("\n7.leading zeros no1 =>\t"+numberOfLeadingZeros(no1));
System.out.println("\n8.trailing zeros no1=>\t"+numberOfTrailingZeros(no1));
System.out.println("\n9.reverse no 1 =>\t"+reverse(no1));
System.out.println("\n7.rotate right =>\t"+RotateRight(no1));
System.out.println();
}
}

0 comments:

Post a Comment