blog-post-1

JavaScript Bitwise Operations

 

JavaScript Bitwise Operations


JavaScript Bitwise Operations

OperatorNameDescription
&ANDSets each bit to 1 if both bits are 1
|ORSets each bit to 1 if one of two bits is 1
^XORSets each bit to 1 if only one of two bits is 1
~NOTInverts all the bits
<<Zero fill left shiftShifts left by pushing zeros in from the right and let the leftmost bits fall off
>>Signed right shiftShifts right by pushing copies of the leftmost bit in from the left, and let the rightmost bits fall off
>>>Zero fill right shiftShifts right by pushing zeros in from the left, and let the rightmost bits fall off



32 Bits Bitwise Operands

Bitwise AND
One Bit Examples :
OperationResult
0 & 00
0 & 10
1 & 00
1 & 11

4 Bit Examples :
OperationResult
1111 & 00000000
1111 & 00010001
1111 & 00100010
1111 & 01000100


Bitwise OR
One Bit Examples :
OperationResult
0 ^ 00
0 ^ 11
1 ^ 01
1 ^ 10

4 Bit Examples :
OperationResult
1111 | 00001111
1111 | 00011111
1111 | 00101111
1111 | 01001111


Bitwise XOR
One Bit Examples :
OperationResult
0 ^ 00
0 ^ 11
1 ^ 01
1 ^ 10

4 Bit Examples :
OperationResult
1111 ^ 00001111
1111 ^ 00011110
1111 ^ 00101101
1111 ^ 01001011


>_ Sekian kalo ada salah mohon dikoreksi

Comments (3)

Samsudin | 1 hour ago

Makasih infonya min...

Jamal | 5 hours ago

ini yg ku cari cari.

Rizky | 12 hours ago

KELASSS.

Leave a Comment