How number bases work
A base (or radix) is how many digits a number system uses. Decimal uses ten (0–9), binary two (0 and 1), octal eight (0–7) and hexadecimal sixteen (0–9 then A–F). Each position is worth the base times the position to its right, so hex 2F is 2 × 16 + 15 = 47.
Hex to decimal: the formula with an example
Multiply each hex digit by 16 raised to its position, counting from 0 on the right, and add the results. A to F stand for 10 to 15. For 1A3F:
1 × 16³ = 1 × 4096 = 4096
A × 16² = 10 × 256 = 2560
3 × 16¹ = 3 × 16 = 48
F × 16⁰ = 15 × 1 = 15
----
6719 Binary to decimal with an example
Same idea with powers of 2: write 1, 2, 4, 8, 16… under the digits from the right and add the ones that sit under a 1. For 101101: 32 + 8 + 4 + 1 = 45.
Decimal to hex or binary
Divide by the target base repeatedly and write down the remainders; read them from the last to the first. 6719 to hex: 6719 ÷ 16 = 419 remainder 15 (F), 419 ÷ 16 = 26 remainder 3, 26 ÷ 16 = 1 remainder 10 (A), 1 ÷ 16 = 0 remainder 1, so the answer is 1A3F. For binary, divide by 2 instead: 45 gives the remainders 1, 0, 1, 1, 0, 1, read backwards as 101101.
Conversion table: 0 to 15
One hex digit is exactly four binary digits, so this table is all you need to convert between hex and binary by hand: 0x2F is 0010 1111.
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
Hex values worth knowing
| Hex | Decimal | Where you see it |
|---|---|---|
7F | 127 | Largest signed byte, the last ASCII character |
FF | 255 | Largest byte; full colour channel in #FFFFFF |
100 | 256 | Number of values in one byte |
3E8 | 1000 | |
FFFF | 65,535 | Largest 16-bit value, highest port number |
7FFFFFFF | 2,147,483,647 | Largest 32-bit signed integer (Java Integer.MAX_VALUE) |
FFFFFFFF | 4,294,967,295 | Largest 32-bit unsigned integer |
A hex colour is three bytes: #2F6FED is red 2F = 47, green 6F = 111 and blue ED = 237.
Where you meet each base
- Binary: bit flags, network masks, bitwise operations and hardware registers.
- Hexadecimal: colours (
#2F6FED), memory addresses, byte dumps, hashes and UUIDs. One hex digit is exactly four bits, so two digits make a byte. - Octal: mainly Unix file permissions (
chmod 755). - Base 36: compact IDs and short links, since it uses every digit and letter.
Negative numbers and two's complement
Computers store negative integers in two's complement: the value −1 in 8 bits is 11111111 (0xFF), the same bits as unsigned 255. The table above shows both readings for 8, 16, 32 and 64-bit widths whenever the number fits. This explains why a byte read from a file might show as −56 in Java (whose byte is signed) but 200 elsewhere.
Converting in code
- JavaScript:
(255).toString(16)andparseInt('ff', 16); useBigIntfor values beyond 253. - Java:
Integer.toBinaryString(n),Long.parseLong("ff", 16), ornew BigInteger(s, 36). - Python:
bin(n),hex(n),oct(n)andint('ff', 16).
Frequently asked questions
How do I convert binary to decimal?
Type or paste the binary number into the Binary box; the decimal value appears immediately. By hand, add the powers of two where there is a 1: 1011 = 8 + 0 + 2 + 1 = 11.
Is there a size limit?
No. The converter uses arbitrary-precision integers, so numbers with hundreds of digits convert exactly, without the rounding you get beyond 2^53 in ordinary JavaScript numbers.
Can I paste values with 0x or 0b prefixes?
Yes. 0x, 0b and 0o prefixes are accepted, as are spaces, underscores and commas used as digit separators.
Does it convert fractions?
No, only whole numbers (positive or negative). Fractions often have no exact representation in another base; for example 0.1 in decimal repeats forever in binary.
Is anything sent to a server?
No. Conversion happens in your browser.