WPMozo: add-ons and tools for WordPress and Elementor
⚡ Developer · Client-side · No data sent to server

Bitwise Calculator

Apply AND, OR, XOR, NOT, left shift and right shift to two numbers. See results in decimal, hex, binary, and octal with a bit-pattern visualizer. Runs in your browser.

Input A
Input B
Operation
by bits
Result
Decimal 0
Hexadecimal 0x0
Binary 0b0
Octal 0o0
Copied!
32-bit Visualizer (click a bit in A or B to toggle it)
A
B
Result
100% private. All bitwise calculations run entirely in your browser - no numbers, inputs, or results are ever sent to any server.

About this tool

The Bitwise Calculator lets you apply the six fundamental bitwise operations - AND, OR, XOR, NOT, left shift, and right shift - to any two integers. Enter numbers in decimal, hexadecimal, binary, or octal and see the result instantly in all four bases. The 32-bit visualizer shows each operand and the result as a grid of colored squares so you can watch individual bits change in real time.

Bitwise operators work directly on the binary (base-2) representation of integers. AND sets a bit to 1 only when both operands have a 1 in that position - perfect for masking. OR sets a bit when either operand has a 1 - ideal for combining flags. XOR flips a bit when the two operands differ, which is the basis of many encryption and checksum algorithms. NOT inverts every bit, producing the one's complement of a number. Left shift multiplies by powers of two; right shift divides (arithmetic shift, preserving the sign bit).

All values are treated as signed 32-bit integers following JavaScript's standard integer coercion rules. Negative numbers are represented in two's complement, which means the most significant bit (bit 31) acts as the sign bit. The visualizer handles this correctly: -1, for example, shows all 32 bits set to 1.

Common real-world uses include reading and writing Unix file permissions (rwx stored as bits 8-6, 5-3, 2-0), extracting RGBA channel values from packed color integers (e.g. red = color >> 16 & 0xFF), implementing fast power-of-two checks (n & (n - 1) === 0), toggling feature flags stored in a bitmask, and performing fast modulo on powers of two (x % 8 is equivalent to x & 7).

The interactive bit grid lets you toggle individual bits in A or B by clicking them - handy when you want to explore what a specific bit combination produces without doing the mental arithmetic of building the decimal value first. Shift amount for left and right shifts can be set between 1 and 31 bits. Hexadecimal input is accepted with or without the 0x prefix; binary with or without 0b; octal with or without 0o.

DiviExtended: premium Divi child themes and plugins