5 << 2 << 5 What does this mean? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

5 << 2 << 5 What does this mean?

30th Dec 2020, 3:41 AM
Aliyar
Aliyar - avatar
5 Answers
+ 2
Hello, << (left shift) Takes two numbers, left shifts the bits of the first operand, the second operand decides the number of places to shift. Or in other words, left shifting an integer โ€œxโ€ with an integer โ€œyโ€ (x<<y) is equivalent to multiplying x with 2^y (2 raised to power y) << have left to right associativity so 5<<2 is evaluated then (5<<2)<<5 is evaluated First 5 is converted to binary and 2 bit is shifted to left so the answer is 20 then 20<<5 is performed so the answer is 640
30th Dec 2020, 4:03 AM
AjayGohil
0
Thanks Vandivelan but I don't understand bits๐Ÿ˜‚๐Ÿ˜‚
30th Dec 2020, 3:47 AM
Aliyar
Aliyar - avatar
0
ok thanks, I will try my best to understand her๐Ÿ˜... (I said her because it's hard to understand girls too๐Ÿ™„)
30th Dec 2020, 3:50 AM
Aliyar
Aliyar - avatar