0

why print(2 <<3)is 16?

14th Jul 2020, 7:17 PM
Sandeep Thakur
Sandeep Thakur - avatar
3 ответов
+ 7
its in binary 2 equals 0010 (0010 << 3) == 0001 0000 #left shift 3 0001 0000 equals 16
14th Jul 2020, 7:18 PM
Slick
Slick - avatar
+ 3
Please use the search bar, similar questions have been asked may times https://www.sololearn.com/learn/4087/?ref=app
14th Jul 2020, 7:33 PM
Namit Jain
Namit Jain - avatar
+ 3
Another attempt in addition to what Slick wrote: 2 = 2^1 Left shift by three adds 3 to exponent so it is 2^(1+3) = 2^4 = 16
14th Jul 2020, 7:36 PM
G B
G B - avatar