Bit/Register Calculator

Set, clear, and toggle individual bits in an 8/16/32-bit register with live hex/binary output.

Decimal

0

Hexadecimal

0x00

Binary

0000 0000

For reference and prototyping. Verify any safety- or design-critical value against the component datasheet or a second method before relying on it. Full disclaimer.

About this tool

Click any bit to set, clear, or toggle it, and watch the decimal, hex, and binary representations update instantly — the everyday task of figuring out what value to write to a microcontroller register to turn specific bits on or off. Type a value directly (hex, binary, or decimal) to load it into the bit grid instead.

Why registers are edited bit-by-bit. A microcontroller's control and status registers pack many independent on/off flags into a single byte or word — for example, one register might have separate bits enabling a timer, selecting its clock source, and setting its interrupt priority, all in the same 8-bit value. Writing the whole register at once means figuring out which bits need to be 1 and which need to be 0, then combining them into one number — exactly the arithmetic this tool does visually instead of on paper.

Bit numbering. Bit 0 (the least significant bit, worth 2⁰ = 1) is conventionally the rightmost bit, matching how binary numbers are normally written and read left-to-right from most to least significant. In an 8-bit register the bits run 7 6 5 4 3 2 1 0 left to right; a 16-bit register runs 15 down to 0, and 32-bit runs 31 down to 0.

Worked example. To set bits 0, 2, and 5 (and leave the rest clear) in an 8-bit register: bit 0 is worth 1, bit 2 is worth 4, bit 5 is worth 32, and 1 + 4 + 32 = 37 decimal = 0x25 hex = 0b00100101 binary. Clicking exactly those three bits in the grid produces that same value across all three formats simultaneously.

Entering a value directly. Type a number with the matching prefix — 0x for hexadecimal (0x1F), 0b for binary (0b00011111), or no prefix at all for plain decimal (31) — and the bit grid, along with the other two formats, updates the moment it parses successfully.

The three bulk operations mirror the three bitwise operators every register datasheet describes: "Set all" is a logical OR with all 1s, "Clear all" is an AND with all 0s, and "Invert" is a bitwise NOT, flipping every bit to its opposite — useful for quickly building the complement of a bit mask.

For the underlying number-base conversions on their own, see the binary translator. For checksum math that also operates bit-by-bit on register-width data, the CRC calculator.

Frequently asked questions

Which end is bit 0?
Bit 0 (the least significant bit) is on the right, matching how binary numbers are normally written and read — the leftmost bit is the most significant bit (bit 7, 15, or 31 depending on width).
How do I enter a value?
Type it with a prefix: 0x1F for hex, 0b00011111 for binary, or just 31 for decimal — the bit grid and other formats update as soon as it parses.
What happens if I switch register width after setting bits?
The current decimal value carries over and is re-rendered into the new bit width — switching to a narrower width truncates any bits beyond the new width, since they no longer exist in the register.
What do "Set all," "Clear all," and "Invert" actually do?
They're the three basic bitwise operations applied to the whole register at once: Set all ORs in all 1s, Clear all ANDs in all 0s, and Invert (NOT) flips every bit — handy for quickly building a bit mask's complement.
Why would I need a 16-bit or 32-bit register instead of 8-bit?
Many microcontroller peripherals (timers, DMA controllers, some GPIO ports) use wider registers than the classic 8-bit ones from simpler chips like the AVR family — switch width to match whatever your datasheet specifies for the register you're working with.
Is this specific to one microcontroller family?
No — bit manipulation works identically across AVR, ARM Cortex-M, PIC, ESP32, and virtually every other architecture. Only the specific bit meanings (what bit 3 of a particular register does) are chip-specific, and that comes from the datasheet, not this tool.
Can I copy the value straight into my code?
Yes — "Copy hex" copies the hex representation, which is the most common way register values are written in embedded C (e.g. PORTB = 0x25;); read off the binary or decimal display if your code needs a different literal format.