Bitwise Calculator
Calculate bitwise AND, OR, XOR, NOT, left shift and right shift operations online. Enter integers in decimal, binary or hexadecimal notation and instantly see the results in decimal, binary and hexadecimal formats. Useful for programming, computer science, digital electronics and learning how individual bits work.
Bitwise operations calculator
Enter your numbers and select an operation. This calculator uses JavaScript 32-bit integer behavior. The display width controls the binary result length and the mask used for the NOT operation.
0b, or hexadecimal with 0x.
What are bitwise operations?
Bitwise operations manipulate the individual bits of integer values. Instead of comparing complete numbers, they examine corresponding binary positions and apply a logical rule to each bit.
Computers represent numbers using binary digits: 0 and 1.
For example, decimal 12 is binary 1100, while decimal
10 is binary 1010. A bitwise operation can compare
these two binary values position by position.
Bitwise operators are commonly used in programming, binary data processing, permissions, hardware control, network protocols, embedded systems and digital electronics.
Bitwise operators explained
| Operation | Symbol | Rule |
|---|---|---|
| AND | & |
Produces 1 only when both corresponding bits are 1. |
| OR | | |
Produces 1 when at least one corresponding bit is 1. |
| XOR | ^ |
Produces 1 when the corresponding bits are different. |
| NOT | ~ |
Inverts every bit in the integer representation. |
| Left shift | << |
Moves bits to the left, filling the right side with zeros. |
| Signed right shift | >> |
Moves bits to the right while preserving the sign bit. |
| Unsigned right shift | >>> |
Moves bits right and fills the left side with zeros. |
Bitwise AND, OR and XOR truth table
The following truth table shows how the three main binary bitwise operators process individual bits.
| Bit A | Bit B | A AND B | A OR B | A XOR B |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 |
Example: calculate 12 AND 10
Convert both decimal values into binary:
| Number | Decimal | Binary |
|---|---|---|
| A | 12 | 1100 |
| B | 10 | 1010 |
| A AND B | 8 | 1000 |
The AND operation produces 1 only where both input bits are 1.
The resulting binary number is 1000, which equals
decimal 8.
Example: XOR operation
Consider 12 XOR 10.
The binary values are 1100 and 1010.
The result is binary 0110, which equals decimal 6.
How do bit shifts work?
Left shift example
A left shift moves the binary digits to the left. For example:
Shifting 5 left by two positions produces 20. For values where no significant bits are lost, a left shift by one position is equivalent to multiplying by 2.
Right shift example
A right shift moves bits toward the least significant position. For a positive value:
Signed right shift preserves the sign bit, while unsigned right shift fills the leftmost positions with zeros. The difference matters when working with negative values or values whose highest bit is set.
How to use the bitwise calculator
- Enter the first integer in decimal, binary or hexadecimal notation.
- Enter a second integer or shift amount when the selected operation requires it.
- Choose AND, OR, XOR, NOT, left shift, signed right shift or unsigned right shift.
- Select an 8-bit, 16-bit or 32-bit binary display width.
- Click Calculate to see the result in decimal, binary and hexadecimal.
- Use Copy result details to copy the calculation.
Binary inputs should start with 0b, such as
0b1100. Hexadecimal inputs should start with
0x, such as 0xC.
What are bitwise operations used for?
1. Setting and checking flags
AND and OR can be used to check or set individual flags stored inside an integer. This is useful when multiple Boolean settings are represented by a single number.
2. Working with permissions
Software can represent permissions using individual bits. Bitwise AND can test whether a permission flag is enabled, while OR can combine permission flags.
3. Embedded systems and electronics
Bitwise operators are useful when reading or changing individual hardware register bits, controlling devices and processing binary signals.
4. Data processing
XOR, shifts and masks are frequently used in low-level programming, encoding, data manipulation and certain checksum algorithms.
Understanding 32-bit integer results
JavaScript converts operands to signed 32-bit integers when performing bitwise operations. This means the accepted input range in this calculator is -2147483648 to 4294967295.
The same 32-bit pattern can be interpreted as either a signed
or unsigned number. For example, the bit pattern
11111111111111111111111111111111 represents
-1 as a signed 32-bit integer and 4294967295 as an unsigned
32-bit integer.
The calculator displays both interpretations. The selected binary width affects the displayed result and the NOT mask; it does not change the underlying 32-bit behavior of the JavaScript bitwise operators.
Frequently asked questions
What is a bitwise calculator?
A bitwise calculator performs operations directly on the binary digits of integer values. It can calculate AND, OR, XOR, NOT and bit shifts and display the results in different number systems.
What is the difference between bitwise AND and OR?
AND produces 1 only when both corresponding bits are 1. OR produces 1 when at least one of the corresponding bits is 1.
What does XOR mean in binary?
XOR means exclusive OR. It produces 1 when two corresponding bits are different and 0 when they are the same.
Why can bitwise NOT produce a negative number?
JavaScript uses signed 32-bit integers for bitwise operations. Inverting all 32 bits can therefore produce a negative signed decimal result. The calculator also shows the unsigned interpretation and the selected-width binary representation.
What is the difference between signed and unsigned right shift?
Signed right shift preserves the sign bit. Unsigned right shift fills the leftmost positions with zeros. This can produce different results when the input has its highest 32-bit position set.
Can I enter binary and hexadecimal numbers?
Yes. Enter binary values with a 0b prefix, such as 0b1010, and hexadecimal values with a 0x prefix, such as 0xA. Decimal integers can be entered directly.
Does the 8-bit setting change the arithmetic to 8 bits?
No. The underlying bitwise arithmetic uses JavaScript's 32-bit integer behavior. The 8-bit and 16-bit settings control the displayed binary width and the mask used for the NOT operation.
Related binary and logic calculators
Explore more tools for binary conversion, hexadecimal values and Boolean logic.