Loading Please Wait...

Logo Lynxsia IT Solutions

JavaScript Bitwise Operators

JS Bitwise Operators

Comparison operators are used in logical statements to determine equality or difference between variables or values and return either true or false.

JavaScript stores numbers as 64 bits floating point numbers, but all bitwise operations are performed on 32 bits binary numbers.

JavaScript Bitwise Operators
Operator Name
& AND
| OR
~ NOT
^ XOR
<< Zero fill left shift
>> Signed right shift
>>> Zero fill right shift
Bitwise AND
Operation Result
0 & 0 0
0 & 1 0
1 & 0 0
1 & 1 1
Bitwise AND
Decimal Binary
5 00000000000000000000000000000101
1 00000000000000000000000000000001
5 & 1 00000000000000000000000000000001 (Decimal = 1)
Bitwise OR
Operation Result
0 | 0 0
0 | 1 1
1 | 0 1
1 | 1 1
Bitwise OR
Decimal Binary
5 00000000000000000000000000000101
1 00000000000000000000000000000001
5 | 1 00000000000000000000000000000101 (Decimal = 5)
Bitwise XOR
Operation Result
0 ^ 0 0
0 ^ 1 1
1 ^ 0 1
1 ^ 1 0
Bitwise XOR
Decimal Binary
5 00000000000000000000000000000101
1 00000000000000000000000000000001
5 ^ 1 00000000000000000000000000000100 (Decimal = 4)
Bitwise NOT
Operation Result
~0 1
~1 0
Bitwise NOT
Decimal Binary
5 00000000000000000000000000000101
~5 11111111111111111111111111111010 (Decimal = -6)
Bitwise Left Shift
Decimal Binary
5 00000000000000000000000000000101
5 << 1 00000000000000000000000000001010 (Decimal = 10)
Bitwise Right Shift (Signed)
Decimal Binary
-5 11111111111111111111111111111011
-5 >> 1 11111111111111111111111111111101 (Decimal = -3)
Bitwise Right Shift
Decimal Binary
5 00000000000000000000000000000101
5 >>> 1 00000000000000000000000000000010 (Decimal = 2)

How you feel about this blog:

Share this blog on:

Report Us

If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com

Contact Us
Ads
Logo
Lynxsia IT Solutions

We are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..

Kotwali Road, Chhiptehri, Banda, 210001, UP, India

Copyright © 2022, Lynxsia IT Solutions, All rights reserved