+ 24
3<<1 = 6
Can you please tell me what is the meaning of this?and why the answer is "6"...help me
16 Antworten
+ 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
+ 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
+ 9
Thanks Edwin 👍👍
+ 9
Thanks Knight Wing bro🤪
+ 8
Thanks κεvιπ lεvιπ 👍👍
+ 7
Thanks Electron_03 👍👍
+ 7
I've made a code which may help you:)
https://code.sololearn.com/cVjKpb1ZmzU8/?ref=app
+ 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
+ 5
👏👏Nice question. I have this doubt
+ 5
Sharanka Sri 👍😋
+ 4
This can help you :) there is a bits table of memory representation :
https://www3.ntu.edu.sg/home/ehchua/programming/java/datarepresentation.html
+ 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 )
+ 1
coooool bro
- 1
L rule error
- 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