Bitwise Calculator

Calculate AND, OR, XOR, NOT and shifts — see every bit.

AND returns 1 only when both input bits are 1. Inputs use 8-bit fixed-width binary.

Try:

Bitwise Calculator Online with Binary, Decimal and Hex Results

A bitwise calculator helps you apply binary operations to integers and understand exactly how individual bits change. Instead of working with the entire number as one decimal value, bitwise operations inspect the binary digits in specific positions. This is useful in computer science, programming, digital electronics, embedded systems, networking and data-structure exercises.

Our bitwise calculator online performs AND, OR, XOR, NOT, left shift, arithmetic right shift and logical right shift. It also acts as a bitwise operator calculator, bitwise operators calculator, bitwise operation calculator and bitwise operations calculator. Enter numbers in decimal, binary or hexadecimal; choose an 8-, 16-, 32- or 64-bit width; then calculate to see the unsigned decimal, signed decimal, hex and binary output.

The interactive bit diagram is the most useful part for beginners. It lines up the binary digits of the input values, marks 1 bits in green, and shows the final output underneath. This makes it easier to spot the difference between bitwise AND and OR, understand a shift, and check homework answers without a complicated binary conversion process.

Quick example: 12 AND 10

The binary representation of 12 is 00001100, and 10 is 00001010. Bitwise AND keeps only the bit positions where both numbers contain 1. The result is 00001000 = 8. Change the operation to OR and the result becomes 14, or XOR and the result becomes 6.

How to Use the Bitwise Calculator with Steps

  1. Choose an operation. Select AND, OR, XOR, NOT or a left/right shift from the menu.
  2. Set the input format. Decimal is the default, but you can select binary or hexadecimal.
  3. Choose the bit width. Start with 8 bits for easy examples. Use 32 or 64 bits when the programming exercise specifies that size.
  4. Enter A and B. For NOT, only A is needed. For shifts, B is the number of positions to shift.
  5. Calculate. The tool displays the result in signed decimal, unsigned decimal, binary and hex.
  6. Check the steps. Read the binary visualization and explanation to see where each output bit came from.

If you are looking for a bitwise calculator with steps, the worked output makes the calculation visible rather than returning only one number. You can also use this page as an online bitwise calculator or bitwise calculator tool when checking code examples in C, Java, Python or other languages.

Bitwise AND Calculator: How to Calculate Bitwise AND

The AND operator compares corresponding bits of two numbers. An output bit is 1 only if both input bits are 1. All other input pairs produce 0. This makes AND useful for testing bit flags, clearing unwanted bits and masking data in programming.

A AND B = A & B

To understand how to calculate bitwise and and how to calculate bitwise operators in general, convert both integers into binary values of the same width and place them one above the other. Compare each column, from the rightmost bit toward the left. Write 1 if the two bits are 1; otherwise write 0. A bitwise and calculator, bitwise and operator calculator or and bitwise calculator automates exactly that comparison.

For example, 12 is 1100 and 10 is 1010 in four-bit binary. Both have the 8's bit set, so 12 & 10 is 1000, or 8. The same result is obtained whether the input is decimal, binary or hex, provided the values and width are equivalent. If a student searches for an and calculator, this is the bitwise meaning—not a logical true/false AND expression.

Bitwise OR Calculator: How to Calculate Bitwise OR

The OR operator keeps a bit set if at least one of the two input bits is 1. Only a 0/0 pair produces 0. A bitwise or calculator is often used to set or combine bit flags. The or bitwise calculator option on this page uses the vertical-bar symbol: A | B.

12 | 10 = 00001100 | 00001010 = 00001110 = 14

If you wonder how to calculate bitwise or, write both numbers in binary, align the positions, and take the OR of each pair. For example, 12 contributes set bits at positions 3 and 2, while 10 contributes set bits at positions 3 and 1. The combined result has positions 3, 2 and 1 set, producing 14. This approach is also used in a bitwise operator online tool when visualizing flags and bit fields.

XOR Bitwise Calculator and Exclusive OR

XOR, short for exclusive OR, returns 1 only when the two compared input bits differ. It returns 0 for 0/0 or 1/1. The operator is commonly written as ^ in C, Java, JavaScript and Python. A xor bitwise calculator is useful for studying binary differences, parity checks and bit-flipping operations.

12 ^ 10 = 00001100 ^ 00001010 = 00000110 = 6

For a bit set in both inputs, XOR clears it. A bit present in only one input stays set. XOR is different from OR because OR keeps the 1/1 combination as 1, but XOR produces 0 in that case. The same XOR rule applies to any selected width.

Bitwise NOT Calculator: How to Calculate Bitwise NOT

NOT is a one-input operation that reverses every bit: 0 becomes 1, and 1 becomes 0. In most programming examples, NOT is written with a tilde (~). The result depends on the bit width, because the operator flips every available bit. Our calculator shows exactly how this works within 8, 16, 32 or 64 bits.

8-bit NOT of 12: ~00001100 = 11110011 = 243 unsigned (−13 signed)

Students asking how to calculate bitwise not should pay particular attention to signed and unsigned interpretation. The 8-bit pattern 11110011 has unsigned decimal value 243, but when read as signed two's complement, it represents −13. These are two interpretations of the same bits. Python's arbitrary-precision ~12 also equals −13, while a fixed-width view of its bits needs an explicit mask.

Bit Shift Calculator: Left, Signed Right and Logical Right

A bit shift calculator moves binary digits by a specified number of positions. A left shift moves bits toward higher bit positions and fills newly empty low positions with zeros. A right shift moves digits toward lower positions. A bitwise calculator shift feature is especially useful for data packing, binary masks and understanding low-level programming operators.

Left Shift Bitwise Calculator (A << B)

The left shift bitwise calculator option shifts A left by B places. With an 8-bit width, 5 is 00000101. Shifting left by two positions gives 00010100, or 20. Shifted-out high bits are discarded in this fixed-width calculator.

5 << 2 = 00000101 << 2 = 00010100 = 20

When no high bits are lost, shifting a positive integer left by one position is equivalent to multiplying it by two. But that shortcut does not always hold within a fixed width. For example, 200 << 1 in eight bits produces 144, because the ninth bit is discarded. Selecting the correct width is essential.

Arithmetic Right Shift (A >> B)

A signed or arithmetic right shift preserves the sign bit of the fixed-width two's-complement value. For example, the 8-bit pattern 11110000 is −16 when signed. Shifting it arithmetically right by two positions gives 11111100, which is −4 signed or 252 unsigned. This is useful when examining signed integer behavior.

Logical Right Shift (A >>> B)

A logical right shift fills empty high positions with zeros instead of copying the sign bit. With eight-bit input 11110000, a logical right shift by two gives 00111100, or 60. It uses the same input bits as the arithmetic shift but produces a different answer because the new high bits are zero.

Our shift operations use an explicit fixed-width model. That makes the results predictable, but it is not an exact simulation of every programming language. Java and JavaScript have particular integer sizes and shift-count rules, and Python does not have a native >>> operator. Always check your language's semantics when copying a shift result into code.

Binary Bitwise Calculator with Visual Bits

The binary bitwise calculator mode allows values such as 1010, 11001100 or 0b1010. Binary numbers use only digits 0 and 1. When you select Binary, the calculator converts the current valid values so you can inspect or edit their bit patterns directly. In the results, all bits are displayed at the chosen width, with spaces between groups of four to improve readability.

For instance, 15 in decimal is 00001111 in eight-bit binary. Performing bitwise AND with 3 (00000011) leaves 00000011, or 3. You can verify the same answer using decimal entries 15 and 3 or binary entries 1111 and 11. For larger numbers, the visual bit table can scroll horizontally on mobile instead of stretching the page.

Hexadecimal Bitwise Calculator: AND, OR, XOR and Masks

A hex bitwise calculator or hexadecimal bitwise calculator works with base-16 numbers, which use 0–9 and A–F. Hex is convenient because one hex digit corresponds exactly to four binary bits. For example, 0xF0 equals 11110000 in binary, and 0x0F equals 00001111. Their bitwise OR is 0xFF, whereas their AND is 0x00.

0xF0 ^ 0x0F = 0xFF = 255 = 11111111

The bitwise calculator hex mode accepts plain hex values or values prefixed with 0x. Use it for understanding hexadecimal bit masks, configuration flags and individual bytes. The output shows hex and binary together so you can check what changed. Unlike a basic numeric converter, the calculator also explains how the selected bitwise operator produces the result.

Bitwise Operator Truth Table

Each basic binary operator acts independently on corresponding pairs of bits. Here is the truth table for AND, OR and XOR. NOT is a unary operator: NOT 0 is 1 and NOT 1 is 0.

ABA AND BA OR BA XOR B
00000
01011
10011
11110

This table explains why bitwise operations are different from everyday arithmetic. Instead of adding or subtracting whole numbers, the operator combines each column according to its own rule. In programming, bitwise operators commonly work with integer bit patterns, while logical AND/OR operators may treat entire values as true or false.

Bitwise Calculator in C and C++

A c bitwise calculator helps verify C expressions such as a & b, a | b, a ^ b, ~a, a << n and a >> n. Students may also search for a bitwise calculator in c while learning masks and integer operators. In C, the widths of integer types matter; signed and unsigned shifts also have different constraints, and some signed operations are not safe to treat as interchangeable with simple fixed-width arithmetic.

C example: unsigned int a = 12, b = 10; a & b = 8; a | b = 14; a ^ b = 6;

This tool uses a configurable 8-, 16-, 32- or 64-bit model with explicit masking for learning. It is not a full C compiler and does not model integer promotions, all implementation-defined behavior or undefined behavior. If you are debugging a C program, confirm the actual integer type and platform width before interpreting results.

Java Bitwise Calculator and Java Operators

A java bitwise calculator can help students compare expressions using Java's &, |, ^, ~, <<, >> and >>> operators. The question how to calculate bitwise operators in java begins with converting the operands to binary and understanding that Java's int type is 32 bits while long is 64 bits. Java's >> is a signed right shift; >>> is a zero-fill right shift.

Java also masks the shift distance to the low five bits for int or low six bits for long. Our calculator instead applies the requested shift count directly to the selected fixed-width value. When verifying real Java code, choose 32 or 64 bits and remember that very large shift counts can behave differently because of Java's masking rule. For example, shifting an int by 32 is the same as shifting it by 0 in Java, whereas this learning tool shifts all 32 places.

Bitwise Calculator Python: Bitwise Operations in Python

A bitwise calculator python search often refers to Python's bitwise operators &, |, ^, ~, << and >>. Python integers are not limited to a fixed 8-, 16- or 32-bit storage width, so a result involving NOT or a negative number may look different from an unsigned hardware register. Python does not provide a built-in >>> unsigned-right-shift operator.

For example, in Python, ~12 evaluates to −13. In our 8-bit calculator, NOT 12 produces the binary pattern 11110011, shown as 243 unsigned and −13 signed. To obtain the same unsigned pattern in Python, mask the result with 255: (~12) & 0xff. This illustrates why an explicit bit width is useful when studying two's-complement values.

Bitwise Calculation Examples with Steps

Expression8-bit binary outputUnsigned result
12 & 10000010008
12 | 100000111014
12 ^ 10000001106
~1211110011243
5 << 20001010020
12 >> 2000000113
240 >>> 20011110060

These examples use an eight-bit width and the calculator's defined signed-right-shift behavior. Select the examples above the Calculate button to experiment. You can copy the final result and inspect the expanded steps to understand the binary transformation.

Bitwise Calculator Image and Visual Representation

Some students search for bitwise calculator images or a bitwise calculator image because a visual example is easier to understand than a formula alone. Rather than showing a static picture, the visual table above updates for any inputs you enter. It displays each bit position, the first operand, the second operand when needed, and the final bit pattern.

This is particularly useful for checking shift direction, understanding why the high bit becomes the sign bit in two's complement, and comparing OR and XOR on the same values. You can use the binary row display as a reference while solving digital-logic exercises or writing bitwise code.

Important Notes About Signed and Unsigned Results

The calculator computes a result as a fixed-width sequence of bits. It then shows two decimal interpretations of that pattern: unsigned and signed two's complement. For eight bits, unsigned values range from 0 to 255, while signed values range from −128 to 127. For 16 bits, these ranges become 0 to 65,535 and −32,768 to 32,767.

Decimal negative operands are accepted if they fit the selected signed range; the calculator encodes them in two's complement. Positive operands can use the full unsigned range. Binary and hex inputs represent raw nonnegative bit patterns. If a positive value has its highest bit set, its signed interpretation will be negative, which matters for arithmetic right shift.

Bitwise NOT and left shift are masked to the selected width so their results cannot silently grow beyond the declared number of bits. Right shifts differ: arithmetic right shift extends the sign bit, while logical right shift fills with zero. These choices are explained with each result.

Frequently Asked Questions About Bitwise Calculator

1. What is a bitwise calculator?

It performs operations directly on the individual binary bits of integers. This tool supports AND, OR, XOR, NOT and left or right shifts.

2. How to calculate bitwise AND?

Convert both numbers into binary and write 1 only where the two corresponding bits are both 1. For example, 12 & 10 = 8.

3. How to calculate bitwise OR?

Compare each bit pair and write 1 if at least one input bit is 1. For example, 12 | 10 = 14.

4. How to calculate bitwise NOT?

Reverse each bit within a chosen width. For example, eight-bit ~12 is 11110011, or 243 unsigned and −13 signed.

5. Is XOR the same as OR?

No. XOR returns 0 when both bits are 1, whereas OR returns 1. For example, 12 ^ 10 is 6, but 12 | 10 is 14.

6. Can I enter hexadecimal values?

Yes. Select Hexadecimal and enter values such as F0, 0F or 0xFF. The result is shown in decimal, hex and binary.

7. Can I enter binary values?

Yes. Select Binary and use digits 0 and 1. The optional 0b prefix is supported.

8. What is the difference between >> and >>>?

Arithmetic right shift copies the sign bit; logical right shift fills high positions with zeros. They can produce different results for values with a set sign bit.

9. Does left shift always multiply by two?

Not necessarily. Left shift by one doubles the number only when overflow or discarded high bits do not change the fixed-width result.

10. Does this tool simulate Java bitwise operators exactly?

It uses explicit fixed-width rules. Most simple examples agree, but Java masks shift distances and has defined 32-bit and 64-bit types, so certain large-shift examples differ.

11. Does this tool simulate Python NOT?

The signed value of fixed-width ~12 is −13, like Python's ~12. The unsigned value is the same bit pattern interpreted within the selected width.

12. Can I use 64-bit numbers?

Yes. BigInt-based calculations handle 64-bit fixed-width values without losing precision through floating-point rounding.

13. Can I calculate a left shift and right shift by several positions?

Yes. Enter A, select a shift operation, and enter the shift count in B. The tool updates the binary display accordingly.

14. Is this bitwise calculator free?

Yes. It works directly in your browser without sign-in or an external calculation service.

Calculate Binary Operations Online

Use the bitwise calculator at the top to compare binary numbers, explore bit masks and learn integer operators visually. The calculator returns the numeric result together with aligned binary digits, an explanation and a hexadecimal representation. Check your programming language's integer-size rules when using the output to verify actual code.