deftools.io Developer Tools

Bitwise Calculator

Bitwise AND, OR, XOR, NOT, shifts on 32-bit integers. Visual bit grid, click to toggle bits, results in decimal, hex, binary and octal.

About this tool

Perform bitwise operations on 32-bit integers and see the result in decimal, hex, binary, and octal at once, with a visual bit grid that shows exactly which bits are set. Supported operations: AND (&), OR (|), XOR (^), NOT (~), left shift (<<), sign-propagating right shift (>>), and zero-fill right shift (>>>).

Each operand can be typed in any base — pick Dec / Hex / Bin / Oct, or just prefix the value with 0x, 0b, or 0o and the parser figures it out. Click any bit cell in operand A or B to flip it and watch the result recompute live.

Example: A = 10 (binary ...1010) AND B = 12 (binary ...1100) gives 8 (binary ...1000) — the bits set in both inputs. XOR works the same way for the bits set in exactly one input.

FAQ

Why 32-bit? Can I use 64-bit values?

JavaScript bitwise operators are defined by the ECMAScript spec to operate on 32-bit integers, so this tool matches native AND, OR, XOR, NOT and shift behavior exactly. Values are masked to 32 bits; anything larger is out of range. For 64-bit work, use a BigInt-based tool instead.

What is the difference between signed and unsigned right shift?

The signed right shift (double greater-than) copies the sign bit into the vacated positions, so negative numbers stay negative. The unsigned right shift (triple greater-than) always shifts in zeros, so minus one becomes 4294967295. For positive numbers the two are identical.

Can I enter negative numbers?

Yes. -1 is interpreted as the two-complement 32-bit pattern 0xFFFFFFFF. The result panel shows both the unsigned and signed decimal readings so you can see the same bits either way.

Why does the shift amount seem to wrap around?

In JavaScript, shift amounts are masked to 5 bits (modulo 32), so shifting left by 32 is the same as shifting by 0. This tool follows that rule: only the low 5 bits of operand B are used as the shift count.

What is the popcount field?

Popcount is the number of 1 bits in the result (also called the Hamming weight or population count). It is handy for counting set flags, measuring mask coverage, or checking parity.

More developer tools

Copied!