+ 24

3<<1 = 6

Can you please tell me what is the meaning of this?and why the answer is "6"...help me

25th Apr 2019, 2:51 AM
H.G.N.D Sumanasinghe
H.G.N.D Sumanasinghe - avatar
16 Answers
+ 11
x << y Returns x with the bits shifted to the left by y places (and new bits on the right-hand-side are zeros). This is the same as multiplying x by 2**y. x >> y Returns x with the bits shifted to the right by y places. This is the same as dividing xby 2**y. Here 3*2**1=3*2=6
25th Apr 2019, 2:57 AM
Edwin
Edwin - avatar
+ 9
Because '<<' this is bits operation on the memory. One position to the left. Example: Bits representation : 0011 = 3 Bits operation moving one position to the left '<<' (1) : 0110 = 6
25th Apr 2019, 3:07 AM
electron
electron - avatar
+ 9
Thanks Edwin 👍👍
25th Apr 2019, 4:05 AM
H.G.N.D Sumanasinghe
H.G.N.D Sumanasinghe - avatar
+ 9
Thanks Knight Wing bro🤪
26th Apr 2019, 5:24 PM
H.G.N.D Sumanasinghe
H.G.N.D Sumanasinghe - avatar
+ 8
Thanks κεvιπ lεvιπ 👍👍
26th Apr 2019, 5:24 PM
H.G.N.D Sumanasinghe
H.G.N.D Sumanasinghe - avatar
+ 7
Thanks Electron_03 👍👍
25th Apr 2019, 4:05 AM
H.G.N.D Sumanasinghe
H.G.N.D Sumanasinghe - avatar
+ 7
I've made a code which may help you:) https://code.sololearn.com/cVjKpb1ZmzU8/?ref=app
25th Apr 2019, 10:43 AM
Ayush Sinha
Ayush Sinha - avatar
+ 6
This is actually a question related to bitwise operators which are mostly useful in scientific computing and stuff like that. You are using a bitwise operator called as 'left shift' (<<) in python language. So, before talking about the operation, I will put some points which will help you to understand it in a better way. Any number in this whole universe, can be represented with the help of decimals!!! Yep don't get confused here is an example!! Ex:- 3 is an individual number but it can be expressed as 3.0 or 3.000 or 3.0000000000,etc........ We don't consider them eventually because they are zeroes. But remember every number can be expressed in this manner. So, when you are using an operation like this:- '3<<1', you are actually saying to computer that 'hey, shift 3 by 1 bit to the left!! ' And, what it does is it takes 1 zero after the decimal places and append it to the decimal value of 3 which is 11.After the operation, the resultant number is 110,which is actually equal to 6
25th Apr 2019, 10:33 AM
Ayush Sinha
Ayush Sinha - avatar
+ 5
👏👏Nice question. I have this doubt
25th Apr 2019, 5:13 AM
Saranka Srikanthan
+ 5
Sharanka Sri 👍😋
25th Apr 2019, 5:50 AM
H.G.N.D Sumanasinghe
H.G.N.D Sumanasinghe - avatar
+ 4
This can help you :) there is a bits table of memory representation : https://www3.ntu.edu.sg/home/ehchua/programming/java/datarepresentation.html
25th Apr 2019, 3:09 AM
electron
electron - avatar
+ 2
(3<<0) = 0b00000011 = 3 = 0+0+0+0+0+0+2+1 (0b) this mean that number is written by binary (<<) —> this mean (shift to left) (3<<1) —> shift one bit to left (3<<1) = 0b00000110 = 6 = 0+0+0+0+0+4+2+0 example of conversion from binary to decimal : 10110100 (binary) = 128+0+32+16+0+4+0+0 = 180 (decimal number )
2nd May 2019, 11:44 PM
Ahmed Mohamed AbdElhameed Ali
Ahmed Mohamed AbdElhameed Ali - avatar
25th Apr 2019, 2:17 PM
Basel.Al_hajeri?.MBH()
Basel.Al_hajeri?.MBH() - avatar
+ 1
coooool bro
26th Apr 2019, 12:38 PM
Knight Wing
Knight Wing - avatar
- 1
L rule error
3rd May 2019, 10:14 AM
Ankith Cirgir
Ankith Cirgir - avatar
- 3
<< is the bitwise left shift operator. 3 << 1 means shifting every bit of the binary value of 3 to 1 position left. 3 = 00000111 3 << 1 = 00001110 = 6
26th Apr 2019, 8:53 AM
Nafis
Nafis - avatar