Language
English English Vietnamese (Tiếng Việt) Vietnamese (Tiếng Việt) Chinese (简体中文) Chinese (简体中文) Portuguese (Brazil) (Português do Brasil) Portuguese (Brazil) (Português do Brasil) Spanish (Español) Spanish (Español) Indonesian (Bahasa Indonesia) Indonesian (Bahasa Indonesia)
Hexadecimal to Binary

Hexadecimal to Binary

Expand a register value into bits and see which flags a peripheral has set, with nibble spacing, bit numbering and mask notes for datasheet work.

Opening a Register Value to See Its Flags

A datasheet describes a peripheral register as a map: bit 7 enables the block, bits 5 and 4 pick a clock divider, bit 0 latches an interrupt. Your debugger shows the same register as two hex digits. Expanding those digits back into bits is the step between "the value is 0xA5" and "the enable flag is on and the interrupt is still pending".

One digit unfolds into four bits: take them in order, left to right. 3A becomes 0011 then 1010, so the register reads 00111010.

Two Moments You Need This

A Peripheral Refuses to Start

You read the control register over the debug probe, expand it, and compare each position with the enable bits the datasheet demands.

A Status Word Full of Flags

Error and ready flags share one word; the bit view tells you at once which of them the hardware raised.

The same expansion helps when you design a mask by hand — you can see precisely which positions a value would clear before you write it into an and-operation.

Expanding Hex into Bits

1

Enter the register value

Digits and the letters A to F are accepted in either case and shown capitalised. A pasted 0x prefix loses its x on the way in, so delete the leading zero if one is left behind.

2

Pad out to the register width

The bits appear in groups of four, without leading zeros. For an eight-bit register write the missing zeros in front so the positions you count match the datasheet.

3

Number the positions from the right

The rightmost bit is bit 0. Walk left through the pattern and note which positions hold a 1 — those are the flags the register currently has set.

Composing a value instead: set the bits you want in the lower field and the hex to write appears above. Swap takes you to the binary-first page with the pattern already loaded.

Splitting a Register Value into Bit Fields

Single-bit constants are the ones you meet most often in a driver header. The last column numbers the positions that are set, counting bit 0 at the right, as datasheets do.

HexBits (padded to 8)Positions set
0100000001bit 0
0800001000bit 3
2000100000bit 5
8010000000bit 7
0F00001111bits 0 to 3, the low nibble mask
A510100101bits 0, 2, 5 and 7

Nibble Groups Match the Digits

Bits are spaced in fours, so each group lines up with the hex digit it came from and counting positions stays easy.

Case Makes No Difference

Type a5 or A5 and the same bits appear; the field capitalises what you enter so it matches the datasheet style.

Wide Registers Stay Whole

A 32-bit or 64-bit register value keeps every bit exactly, because long inputs are handled with big-integer arithmetic.

Register and Bit-Field Questions

Why does 0x03 come back as 11 and not 00000011?

The output is the plain value, and a value has no width of its own. Register width is something only you know, so add the leading zeros to reach eight, sixteen or thirty-two positions before you count.

How do I read a multi-bit field out of the pattern?

Take the slice the datasheet names — say bits 5 to 4 — and read those two positions as a small binary number of their own. In 00111010 that slice is 11, which selects setting 3.

Can I paste a whole memory dump line?

Spaces vanish on entry, so several bytes would merge into one very long value. Expand one register at a time if you want the bit positions to mean anything.

Does a bit numbered 7 mean the leftmost one?

In an eight-bit register, yes. Numbering starts at 0 on the right, so bit 7 sits at the far left of a byte and bit 15 at the far left of a sixteen-bit word.

What does an and-mask of 0F actually keep?

Only the four positions where the mask has a 1 — the low nibble. Every higher bit is forced to zero, which is how a driver isolates a field before comparing it.

0123456789ABCDEFabcdef
0x
01
0b

Single-Bit Register Constants

01 = 00000001
08 = 00001000
20 = 00100000
80 = 10000000
0F = 00001111
A5 = 10100101

Hexadecimal (Base-16)

How a debugger, a register dump or a driver header quotes the value — two digits for a byte, four for a word.

Binary (Base-2)

How the datasheet describes it: one position per flag, numbered from the right so bit 0 is the least significant.

Pad the answer to the register width before counting positions
3A unfolds to 0011 1010
Bit 0 is the rightmost position, bit 7 the left of a byte
Lower-case a-f is accepted and shown capitalised
Want to learn more? Read documentation →
1/5
Start typing to search...
Searching...
No results found
Try searching with different keywords