{ Bitwise Calculator }

// calculate bitwise instantly

Perform bitwise AND, OR, XOR, NOT, left/right shift operations instantly. Visualize binary, hex, decimal results — free, browser-based, no sign-up.

OPERAND A
OPERATION
OPERAND B
⚡

Ready to calculate

Enter values and click Calculate

HOW TO USE

  1. 01
    Enter operands

    Type your values into Operand A and B. Choose DEC, BIN, HEX, or OCT input format per field.

  2. 02
    Select operation

    Click AND, OR, XOR, NOT, SHL, or SHR. NOT uses only Operand A. SHL/SHR shift A by B bits.

  3. 03
    View results

    Click Calculate to see results in all bases plus a visual 32-bit pattern breakdown.

OPERATIONS

AND & OR | XOR ^ NOT ~ SHL « SHR »

INPUT FORMATS

  • 🔢 Decimal (base 10) — e.g. 42
  • 🔣 Binary (base 2) — e.g. 101010
  • 🔷 Hexadecimal (base 16) — e.g. 2A
  • 🔵 Octal (base 8) — e.g. 52

WHAT IS THIS?

A bitwise calculator performs low-level binary operations on integers. Essential for systems programming, embedded development, flags/masks, and understanding how CPUs process data at the bit level.

RELATED TOOLS

FREQUENTLY ASKED QUESTIONS

What is a bitwise AND operation?

AND compares each bit of two numbers. The result bit is 1 only if both corresponding bits are 1. Example: 1010 AND 1100 = 1000. Used for masking bits and checking flags.

What is XOR used for in programming?

XOR (exclusive OR) sets a bit to 1 if the bits differ. It's used for toggling bits, simple encryption, swapping values without a temp variable, and detecting differences between values.

How do left shift and right shift work?

Left shift (<<) moves all bits left by N positions, effectively multiplying by 2^N. Right shift (>>) moves bits right, dividing by 2^N. Example: 5 << 2 = 20.

What does bitwise NOT do?

NOT (~) flips every bit in the number — 0 becomes 1 and 1 becomes 0. For a 32-bit integer, ~N = -(N+1) due to two's complement representation.

Can I input hexadecimal values?

Yes. Select HEX from the base dropdown next to each operand, then type your hex value (e.g. FF, 1A3C). The tool accepts both uppercase and lowercase letters A–F.

What integer size does this calculator use?

This tool operates on 32-bit signed integers, consistent with how JavaScript and most languages handle bitwise operations. Results for NOT will reflect two's complement behavior.

Why is bitwise OR useful?

OR sets a bit to 1 if either corresponding bit is 1. It's commonly used to set specific bits or combine flags — for example, combining read and write permissions in a permission bitmask.

Is this tool free to use?

Yes, completely free. No sign-up, no login, no limits. All calculations run entirely in your browser — no data is sent to any server.

What is a Bitwise Calculator?

A bitwise calculator is a specialized tool that performs operations directly on the binary representations of integers. Unlike arithmetic calculators that work with numbers at a high level, a bitwise calculator manipulates individual bits — the 0s and 1s that form the foundation of all digital data. This type of calculation is fundamental to computer science, systems programming, embedded development, and low-level software engineering.

Our free online Bitwise Calculator supports all six core bitwise operations: AND, OR, XOR, NOT, left shift (SHL), and right shift (SHR). You can enter values in decimal, binary, hexadecimal, or octal format and instantly see results across all four representations, plus a visual 32-bit pattern diagram.

Understanding Bitwise Operations

Bitwise operations treat numbers as sequences of bits and apply logical rules to corresponding bit positions. Here's a breakdown of each operation supported by this tool:

AND (&) — Intersection of Bits

The AND operation compares each pair of corresponding bits. The result bit is 1 only when both bits are 1; otherwise it's 0. This is analogous to logical conjunction. AND is heavily used for bit masking — isolating specific bits in a value. For example, to check if bit 3 is set in a number, you AND it with 0b00001000. If the result is non-zero, that bit is set.

Example: 42 & 15 = 10 (binary: 101010 & 001111 = 001010)

OR (|) — Union of Bits

OR sets a result bit to 1 if either or both of the corresponding bits are 1. It's used to set (turn on) specific bits. If you want to ensure bit 4 is always enabled in a flags variable, you OR it with 0b00010000. OR is commonly used in permission systems, hardware register manipulation, and combining flags.

Example: 42 | 15 = 47 (binary: 101010 | 001111 = 101111)

XOR (^) — Toggle Bits

XOR (exclusive OR) sets a bit to 1 only when the two corresponding bits differ. If both are the same (both 0 or both 1), the result is 0. XOR is uniquely useful because it's its own inverse — XOR-ing with the same value twice returns the original. Applications include simple symmetric encryption, checksums, bit toggling, and even swapping two integers without using a temporary variable.

Example: 42 ^ 15 = 37 (binary: 101010 ^ 001111 = 100101)

NOT (~) — Bit Inversion

NOT is a unary operation that flips every bit in the number. Every 0 becomes 1 and every 1 becomes 0. In most programming languages (including JavaScript and C), NOT on a 32-bit signed integer follows two's complement arithmetic, so ~N = -(N+1). This is useful for creating bit masks that exclude specific bits.

Example: ~42 = -43 (binary: all 32 bits inverted)

Left Shift (<<) — Multiply by Powers of Two

The left shift operation moves all bits toward the most significant position by N places, filling the vacated positions on the right with zeros. This is mathematically equivalent to multiplying by 2^N, and bitwise shifts are often used as a faster alternative to multiplication in performance-critical code. Left shifting by 1 doubles the number; by 2 quadruples it, and so on.

Example: 5 << 3 = 40 (binary: 00000101 → 00101000)

Right Shift (>>) — Divide by Powers of Two

Right shift moves all bits toward the least significant position by N places. Bits shifted off the right end are discarded. For unsigned values or positive signed integers, this is equivalent to integer division by 2^N. It is commonly used to extract specific bit fields from a packed integer or to efficiently compute integer halving.

Example: 40 >> 3 = 5 (binary: 00101000 → 00000101)

Common Use Cases for Bitwise Operations

Bitwise operations appear throughout software engineering in contexts including:

Multi-Base Input and Output

One of the most common challenges when working with bitwise values is converting between representations. Binary is most natural for visualizing bit patterns, but decimal is easier for human arithmetic, and hexadecimal is compact and commonly used in memory dumps and hardware documentation. This tool accepts input in any of these four bases and shows results in all four simultaneously, eliminating the need to mentally convert between representations.

Visual Bit Pattern Display

This calculator includes a 32-bit visual bit pattern display, showing the bits of the input values and the result color-coded by position. This makes it easy to understand exactly which bits were affected by the operation — a critical aid when learning bitwise concepts or debugging complex bitmask logic.

Why Use an Online Bitwise Calculator?

While most programming environments have a REPL or console where you can test bitwise expressions, an online calculator provides a faster, more visual experience without requiring a development environment. Our tool is especially useful for students learning computer science fundamentals, developers working in unfamiliar languages, or anyone who needs a quick reference without opening an IDE. The multi-base output, bit pattern display, and instant feedback make it a practical daily utility for any developer working with low-level data.

☕