Binary, Hex & Decimal Conversion: How to Convert by Hand (and Read Signed Values)
Once you see that 16 = 24, the whole subject gets easy: one hex digit equals exactly four bits, so hex↔binary
needs no arithmetic at all — you just look up nibbles. This guide walks through every conversion by hand: the nibble table, grouping bits into hex,
divide-by-2 and place-value for decimal→binary, summing place values for binary→decimal, and divide-by-16 for decimal→hex. At the end comes the twist that
trips up beginners — the same bits read as 0xFF = 255 unsigned but 0xFF = −1 signed. Check any result in the
Number Base Converter.
Why hex exists — the nibble
Binary is base-2 (digits 0 and 1) and hexadecimal is base-16 (digits 0–9 then A–F). The reason they pair so neatly is purely mathematical:
16 = 24, so a single hex digit covers exactly the same range as four binary bits — a group called a nibble.
That means converting between binary and hex needs no calculation: you translate one nibble at a time straight off this table.
| Hex | Binary (4 bits) | Decimal |
|---|---|---|
| 0x0 | 0000 | 0 |
| 0x1 | 0001 | 1 |
| 0x2 | 0010 | 2 |
| 0x3 | 0011 | 3 |
| 0x4 | 0100 | 4 |
| 0x5 | 0101 | 5 |
| 0x6 | 0110 | 6 |
| 0x7 | 0111 | 7 |
| 0x8 | 1000 | 8 |
| 0x9 | 1001 | 9 |
| 0xA | 1010 | 10 |
| 0xB | 1011 | 11 |
| 0xC | 1100 | 12 |
| 0xD | 1101 | 13 |
| 0xE | 1110 | 14 |
| 0xF | 1111 | 15 |
⚠️ The letters are just digits worth 10–15: 0xA = 1010 = 10, 0xB = 11, 0xC = 12, 0xD = 13, 0xE = 14, 0xF = 15.
There is no “digit” past F in a single hex column — the next value, 16, carries over to 0x10.
Hex ↔ binary by grouping
Binary → hex
Group the bits into sets of four starting from the right, pad the leftmost group with leading zeros if it is short, then map each nibble to one hex digit.
0b110101→ group from the right as0011 0101→ from the table that is0x3and0x5→0x35.
Hex → binary
Go the other way by expanding each hex digit into its 4-bit nibble and concatenating:
0x2F→0x2=0010,0xF=1111→0b00101111.
Because each nibble is independent, there is never any borrowing or carrying between groups. You can paste either form into the Number Base Converter to verify the grouping, and the Bitwise Calculator shows the same values lined up bit by bit when you start doing AND/OR/XOR work.
Decimal → binary (two ways)
Method A — repeated division by 2
Divide by 2 over and over, writing down each remainder (0 or 1). When you reach 0, read the remainders from bottom to top. Converting 13:
- 13 ÷ 2 = 6 r 1
- 6 ÷ 2 = 3 r 0
- 3 ÷ 2 = 1 r 1
- 1 ÷ 2 = 0 r 1
Reading the remainders bottom-up gives 1101 = 13. ✔
Method B — place-value subtraction
Write the powers of two from largest to smallest and ask, for each, “does it fit?” If yes, put a 1 and subtract it; if no, put a 0.
| Power | Value |
|---|---|
2^0 | 1 |
2^1 | 2 |
2^2 | 4 |
2^3 | 8 |
2^4 | 16 |
2^5 | 32 |
2^6 | 64 |
2^7 | 128 |
2^8 | 256 |
Converting 156 against 128 64 32 16 8 4 2 1:
- 128 fits → 1, remainder 28
- 64 too big → 0
- 32 too big → 0
- 16 fits → 1, remainder 12
- 8 fits → 1, remainder 4
- 4 fits → 1, remainder 0
- 2 → 0, 1 → 0
That gives 10011100 = 156. Check: 128+16+8+4 = 156. ✔
Binary → decimal
Going back the other way is just a sum: add the place values for every position that holds a 1. Converting 10110 (positions 16 8 4 2 1):
10110 = 16 + 4 + 2 = 22
The 1s sit in the 16, 4 and 2 columns; the 8 and 1 columns are 0, so they contribute nothing. That is the entire method — multiply each bit by its place value and total it up.
Decimal → hex (divide by 16)
Same idea as divide-by-2, but divide by 16, and remember any remainder from 10 to 15 is written as the letter A–F. Converting 254:
- 254 ÷ 16 = 15 r 14 → low digit 14 = E
- 15 ÷ 16 = 0 r 15 → high digit 15 = F
Reading bottom-up gives 0xFE. Check: F×16 + E = 15×16 + 14 = 240 + 14 = 254. ✔ (And as a binary cross-check, 0xFE = 1111 1110 = 254.)
Notation, bytes & 0xFF
Two prefixes show up everywhere: 0b marks a binary literal (0b1010) and 0x marks a hex literal (0x2F). Plain numbers with no prefix are decimal.
A byte is 8 bits, and since each hex digit is 4 bits, a byte is exactly two hex digits — the high nibble followed by the low nibble. So one byte runs from
0x00 to 0xFF, which is 0 to 255 in unsigned decimal. That “2 hex digits = 1 byte = 8 bits = 0–255” chain is worth memorizing; it is how
memory dumps and register maps are laid out. The Number Base Converter shows the byte range as you type.
The signed twist
Here is the catch that surprises people: the same bit pattern can mean two different numbers, depending on how you agree to read it. Take the byte 0xFF = 1111 1111:
- As an unsigned byte,
0xFF= 255 (the sum of all eight place values). - As a two’s-complement signed byte,
0xFF= −1. Likewise0x80= −128 (the most negative), and0x7F= +127 (the most positive).
In two’s complement the high (leftmost) bit is the sign: 0 means non-negative, 1 means negative. The quick intuition for 0xFF → −1 is that adding 1 to all-ones rolls the byte
over to 0x00 = 0, and the value that is “one less than zero” is −1. The full method — flipping the bits and adding one — is covered step by step in the sibling article on
how computers store negative numbers, and the Two’s Complement Calculator converts any pattern both ways.
1111 1111 is the same eight ones either way — only the convention you read
it with decides whether it is 255 or −1.
FAQ
- Why is hexadecimal used instead of binary?
- Because hex is far more compact while staying perfectly tied to binary. Since 16 = 2^4, one hex digit maps to exactly four bits (one nibble), so a long binary string collapses to a quarter of the characters with zero arithmetic — just look up each group of four. An 8-bit byte that reads 11111111 in binary is simply 0xFF in hex. That readability is why memory addresses, color codes and register values are almost always written in hex. You can confirm any mapping in the Number Base Converter tool.
- How do I convert binary to hex quickly?
- Group the bits into sets of four starting from the right, then translate each group to one hex digit. If the leftmost group has fewer than four bits, pad it on the left with zeros first. For example 0b110101 splits into 0011 and 0101, which are 0x3 and 0x5, giving 0x35. No division or multiplication is needed because each nibble is independent — that is the whole advantage of base-16 over base-10. The Number Base Converter does the grouping for you when you want to double-check.
- What does 0xFF equal in decimal?
- It depends on how you interpret the bits. As an unsigned byte, 0xFF is 1111 1111 = 128+64+32+16+8+4+2+1 = 255, the largest value a single byte can hold. But as a two’s-complement signed byte, the same 0xFF means −1, because the high bit is the sign and all-ones is the encoding for negative one. The bits never change — only the convention you read them with does. The Two’s Complement Calculator shows both readings side by side.
- How many bits are in one hex digit, and how many in a byte?
- One hex digit is exactly 4 bits (a nibble), because 16 = 2^4. A byte is 8 bits, so a byte is written as exactly two hex digits — the high nibble and the low nibble. That is why a byte ranges from 0x00 to 0xFF, which is 0 to 255 in unsigned decimal. Two hex digits per byte is a handy rule of thumb when you read register maps or memory dumps; the Number Base Converter and Bitwise Calculator both work at the byte level.