Log in

View Full Version : I am performing left shift by 1 operation in java


antariksh12
Jan 22, 2017, 10:01 PM
byte b=65;
System.out.println(b<<1);
O/p is 130.How?

CravenMorhead
Jan 23, 2017, 08:46 AM
Write both numbers in binary, if the answer isn't obvious then write down 65 in binary. Add a zero on the right hand side, (The net effect of shifting to the left). Convert resultant number back to decimal. What do you get?