Exact, arbitrary-width integer math. Values are masked to the selected word size using two's-complement rules — the same wrap-around real hardware does.
Computers · digital

Bit Calculator

Binary, hex, octal and decimal — flip bits by hand and watch them combine.
two's complement · BigInt
0xB4 · 8-bit

Value

8-bit
DEC
HEX
OCT
BIN

Bit grid

click any bit to flip it0xB4
bit = 1 bit = 0
At a glance
Bitwise lab

Combine two values, bit by bit

columns line up so you can see each result bit form
0x
0x
Field notes

The ideas behind the bits

How it works

One number, four ways to write it

A whole number is just a number — binary, hex, octal and decimal are only different notations for the same value. Computers store it as bits, group those bits into bytes, and cap the whole thing at a fixed word size (8, 16, 32 or 64 bits). This tool shows all four notations at once, lets you flip individual bits, and applies the same masking and two's-complement wrap-around that real hardware uses.

Worked example

The byte 0xB4 is 180 unsigned, or −76 signed (its top bit is set). In binary it's 1011 0100 — four bits set. Flip the top bit and the unsigned value drops by 128; NOT it and you get 0x4B (75), because every bit inverts.

In the lab, 0xF0 AND 0x3C keeps only the bits set in both0x30. Line the three rows up and each result bit is just its column's AND.

Why does the value wrap when I overflow?

A word size is a fixed number of bits. Anything past the top bit has nowhere to go, so it's dropped — the value "wraps" modulo 2ⁿ. That's exactly what a CPU register does, and it's why 255 + 1 = 0 in a byte.

What's two's complement?

The standard way to store negative integers: the top bit carries a negative weight. In a byte, values 0–127 are themselves; 128–255 represent −128 to −1. Switch to signed to see it — the bits don't change, only how the decimal is read.

Hex vs octal — why hex won?

One hex digit maps to exactly four bits (a nibble), so a byte is two clean hex digits. Octal packs three bits per digit, which doesn't line up with 8-bit bytes — handy for old systems and Unix permissions, but hex fits modern hardware better.

How is 64-bit handled correctly?

JavaScript's normal bitwise operators only work on 32 bits. This tool uses BigInt for everything, so 64-bit shifts, rotates and masks are exact — no silent truncation.