Bitwise Calculator
Perform AND, OR, XOR, NOT and bit shifts on decimal, hex or binary values with an aligned binary view.
= 12 · 0x0C
= 10 · 0x0A
a 0000 1100 b 0000 1010 ────────────────── a AND b 0000 1000
8
Decimal (unsigned)
0x080b000010008Operands and results are masked to the low 8 bits, so overflow wraps around modulo 2^8.
How it works
- Type operand A (and B for two-operand operations) as decimal, hex with a 0x prefix, or binary with a 0b prefix.
- Pick an operation — AND, OR, XOR, NOT, or a shift — and set the shift amount and bit width (8, 16 or 32).
- Read the result instantly in binary, decimal and hex, and copy whichever format you need.
Frequently asked questions
- How do I enter hex or binary numbers?
- Prefix hexadecimal values with 0x (for example 0xFF) and binary values with 0b (for example 0b1010). Anything without a prefix is read as decimal, so you can mix formats freely — one operand in hex and the other in binary works fine.
- What is the difference between >> and >>>?
- The arithmetic shift >> preserves the sign bit, so a negative value stays negative as it shifts right. The logical shift >>> always fills with zeros from the left, treating the value as unsigned. They only differ when the highest bit of the selected width is set.
- What does the bit width setting do?
- It masks every operand and result to the low 8, 16 or 32 bits, exactly like a uint8_t, uint16_t or uint32_t in C. Values that overflow the width wrap around modulo 2^N, which mirrors what real hardware and most programming languages do with fixed-width integers.
- Can I use negative numbers?
- Yes. A negative decimal input is converted to its two’s complement representation at the selected width, so -1 at 8 bits becomes 1111 1111. The result panel shows both the unsigned value and, when the sign bit is set, the signed interpretation.
- Is anything uploaded to a server?
- No. All parsing and arithmetic run in plain JavaScript inside your browser, and no network requests are made. That makes the tool safe for values from proprietary code or device registers, and it keeps every result instant.
About this tool
This bitwise calculator evaluates AND, OR, XOR, NOT, left shift, arithmetic right shift and logical right shift on integers you enter in decimal, hexadecimal (0x prefix) or binary (0b prefix). The result appears the moment you type, shown simultaneously in binary, decimal and hex. The binary view stacks both operands and the result in aligned, 4-bit groups, so you can trace exactly which bits each operation set, cleared or moved — something a plain numeric answer never shows you.
Everything runs client-side in JavaScript; nothing you type leaves the page. The selected bit width — 8, 16 or 32 bits — masks operands and results to the low N bits, the same truncation a fixed-width integer type performs in C, Rust or assembly. Overflowing values wrap modulo 2^N, and negative decimal inputs are stored as two’s complement, so -1 at 8 bits reads as 0xFF. When the result’s sign bit is set, the tool reports both the unsigned value and its signed interpretation.
Typical uses include composing and testing permission flags, checking a value against a subnet or register mask, working out what a C expression like (x >> 4) & 0x0F actually returns, and verifying protocol fields packed into a single byte. It is also a practical teaching aid: the aligned binary rows make it obvious why 12 AND 10 is 8, or how a left shift by one doubles a value until it overflows the width.
Two details worth knowing: >> copies the sign bit while >>> fills with zeros, so they diverge only when the top bit is set; and shift amounts equal to or larger than the width produce 0 (or all ones for a negative arithmetic shift) rather than the surprising modulo behavior some CPUs exhibit. Copy buttons next to each format grab the binary, decimal or hex result for pasting straight into code or documentation.