0

What means the output of cout<<(variable1<<variable2); and cout<<(variable1>>variable2); ?

https://code.sololearn.com/cB9EJBa4eVwL/?ref=app

3rd Feb 2019, 6:47 PM
Pavel JordĂĄn
Pavel JordĂĄn - avatar
2 Answers
+ 2
3 base 10 = 11 base 2 if you left shift (11)2 (based 2) you just add 0's on the right. if a = 000011; and you do a<<3 (left shift a by 3) What you are doing is adding zeroes at the end essentially. a = 011000; On the math part left shift made a = a *(2^3) if you do right shift a>>4 a = 000001 (one of the bits fell off) Its same as - a = a/ (2^4)
3rd Feb 2019, 7:19 PM
Akib
Akib - avatar
0
Thank you so much guys!
3rd Feb 2019, 7:25 PM
Pavel JordĂĄn
Pavel JordĂĄn - avatar