+ 1
What is << operation in c++????
Explain shiftwise
6 Answers
+ 7
Sachin Shah I think you are asking about left shift and right shift operators. So consider this example-
int a = 8; // Now write it's binary representation which is-
00001000 --> This is 8.
a>>1 shifts every digit to right by 1 place. So it becomes-
00000100 --> This is 4.
a<<1 shifts every digit to left by 1 place. So it becomes-
00010000 --> This is 16.
+ 10
⢠Multiply by a power of 2
x = x << 1; // x = x * 2
x = x << 6; // x = x * 64
⢠Divide by a power of 2
x = x >> 1; // x = x / 2
x = x >> 3; // x = x / 8
⢠https://www.sololearn.com/learn/4087/?ref=app
⢠https://www.sololearn.com/learn/4086/?ref=app
⢠https://code.sololearn.com/cRRF49cpSTq7/?ref=app
+ 5
Sachin Shah
This question is missing things. Such as a explicate description. Which makes it challenging to answer.
https://www.sololearn.com/discuss/1316935/?ref=app
https://www.sololearn.com/discuss/333866/?ref=app
+ 2
Its not only used in c++ you can also use it in C or Java for example
+ 2
Thank you
0
Manual thanks dude