This is a java prg pls make me understand why on left shifting 2 by 32 it o/p 10
class hi
{
public static void main(String args[])
{
int a;
a=2<<32;
System.out.println(Integer.toBinaryString(a));
}
}
OUTPUT – 10
This is a java prg pls make me understand why on left shifting 2 by 32 it o/p 10
class hi
{
public static void main(String args[])
{
int a;
a=2<<32;
System.out.println(Integer.toBinaryString(a));
}
}
OUTPUT – 10
System.out.println(Integer.toBinaryString(2<<10));
It will shift 2 i.e 10 by 10 digit to left . Output will look like 100000000000
System.out.println(Integer.toBinaryString(2<<32));
It will shift 2 i.e 10 by 32 digit to left , but int is of 32 bit ~ 4byte which is equivalent of 10.