Why 3 758 096 384 << 1 give 768

Having read the great answer for the Beginner's Guide to Bit Shift? I tested the application (sic):

 3,758,096,384 << 1 

from the Chrome console:

 3,758,096,384 << 1 > 768 3,758,096,384 << 2 > 1536 3758096384 << 1 > -1073741824 
+1
source share
2 answers

That the comma operator is working. This is actually 384 << 1 . (The comma operator evaluates the left side, then evaluates the right side and returns the right side.)

+7
source

It returns 768 because you are using the comma operator incorrectly. 3,758,096,384 << 1 will actually be 384 << 1 , because the comma operator will return the last operand.

+9
source

All Articles