How to Convert Number Bases: Binary, Octal, Decimal, and Hex
To convert a number to another base by hand, repeatedly divide it by the target base and record the remainders. Reading those remainders from bottom to top gives you the digits of the answer. Decimal 202 becomes binary 11001010, octal 312, and hex CA, and every one of those values represents the exact same quantity, just written with a different set of digits.
What a number base actually means
A number base, also called a radix, defines how many unique digits a positional numeral system uses before it has to carry over to the next column. Decimal (base 10) uses ten digits, 0 through 9. Binary (base 2) uses only two, 0 and 1. Octal (base 8) uses eight, 0 through 7. Hexadecimal (base 16) needs sixteen distinct symbols, so it borrows the letters A through F to stand in for 10 through 15.
What makes any of these systems work is positional notation: each digit’s value depends on where it sits, not just what symbol it is. In decimal, the digit 2 in “202” sits in the hundreds column, so it means 2 times 10^2, not just 2. The same idea holds in every base, just with a different power. In binary, each position is a power of 2. In octal, a power of 8. In hex, a power of 16. Once you see a number as “a stack of digit times base-to-some-power,” converting between bases stops being a memorized trick and becomes arithmetic you can redo from scratch every time.
Converting decimal to binary, octal, and hex by hand
Take decimal 202 and convert it to all three other bases using two different hand methods.
Division-remainder method (works for any target base)
Divide repeatedly by the target base, write down the remainder each time, and stop when the quotient hits 0. Reading the remainders from the last one back to the first gives the converted number.
For octal (dividing by 8):
| Step | Division | Quotient | Remainder |
|---|---|---|---|
| 1 | 202 / 8 | 25 | 2 |
| 2 | 25 / 8 | 3 | 1 |
| 3 | 3 / 8 | 0 | 3 |
Read the remainders bottom to top: 3, 1, 2. Decimal 202 is octal 312.
For hex (dividing by 16):
| Step | Division | Quotient | Remainder |
|---|---|---|---|
| 1 | 202 / 16 | 12 | 10 (A) |
| 2 | 12 / 16 | 0 | 12 (C) |
Read bottom to top: C, A. Decimal 202 is hex CA. Notice the remainder 10 becomes the letter A and 12 becomes C, since hex digits above 9 are letters, not two-digit numbers.
Place-value / subtraction method (handy for binary)
For binary specifically, it’s often faster to find the largest power of 2 that still fits inside your number, subtract it, and repeat with what’s left. Powers of 2 near 202 are 128, 64, 32, 16, 8, 4, 2, and 1.
| Power of 2 | Fits in remainder? | Bit | Remainder after subtracting |
|---|---|---|---|
| 128 | Yes | 1 | 202 − 128 = 74 |
| 64 | Yes | 1 | 74 − 64 = 10 |
| 32 | No | 0 | 10 |
| 16 | No | 0 | 10 |
| 8 | Yes | 1 | 10 − 8 = 2 |
| 4 | No | 0 | 2 |
| 2 | Yes | 1 | 2 − 2 = 0 |
| 1 | No | 0 | 0 |
Reading the bit column top to bottom gives 11001010, which is binary for 202. You can check the answer by adding the powers that fit: 128 + 64 + 8 + 2 = 202. That cross-check, adding back the bits you marked as 1, is the fastest way to catch a mistake before you trust the result.
Reading octal and hex back to decimal
Converting the other direction, from octal or hex back to decimal, means multiplying each digit by its place value and adding the results. The classic real-world case where you’ll actually do this by hand is a Unix file permission value from chmod, which is always written in octal.
Take octal 755, a permission mode you’ll recognize if you’ve ever set a script executable for the owner but read-and-execute-only for everyone else. Each digit sits in a power-of-8 column, counting from the right: the ones column (8^0), the eights column (8^1), and the sixty-fours column (8^2).
| Octal digit | Place value | Digit × place value |
|---|---|---|
| 7 | 8^2 = 64 | 7 × 64 = 448 |
| 5 | 8^1 = 8 | 5 × 8 = 40 |
| 5 | 8^0 = 1 | 5 × 1 = 5 |
Add the column: 448 + 40 + 5 = 493. So octal 755 is decimal 493, and if you convert that same value to hex you get 1ED and to binary 111101101.
That binary result is worth a second look, because it reveals why octal shows up in permission notation at all. Group the binary digits into sets of 3, matching the three octal digits: 111 101 101. Each group of 3 bits maps directly onto one octal digit, no carrying or borrowing involved, which is exactly why 7 becomes 111 (read, write, execute all on), the first 5 becomes 101 (read and execute, no write), and the second 5 repeats the same pattern for “others.” Hex works the same way but with groups of 4 bits per digit instead of 3, which is why a byte (8 bits) always fits in exactly 2 hex digits, and why hex shows up everywhere in computing: memory addresses, color codes like #RRGGBB, and error codes are all more compact and easier to scan in hex than in raw binary.
Try it with your own numbers
Typing any of the four fields below updates the other three instantly, so you can check your hand calculations or convert a value you’re staring at in a terminal or a color picker.
Common mistakes and edge cases
Assuming a negative number uses two’s complement. Decimal -18 converts to binary -10010, octal -22, and hex -12, a plain minus sign in front of the magnitude. That’s sign-magnitude representation, not two’s complement. If you’ve written low-level code, you might expect -18 as a signed 8-bit binary value to be 11101110, the two’s complement encoding used inside real CPUs and most programming languages. This tool doesn’t do that; it converts the magnitude and reattaches the sign, which is more intuitive for quick lookups but genuinely different math from what a compiler produces. Don’t paste -10010 into code expecting it to behave like a signed integer.
Typing 0x, 0b, or 0o prefixes. Languages like JavaScript, Python, and C let you write 0xFF, 0b1010, or 0o17 directly in source code, and it’s an easy habit to carry over. This tool expects plain digits in each field (FF, 1010, 17), no prefix, since the field itself already tells the converter which base you mean.
Forgetting hex letters are case-insensitive on input but not on output. You can type ca or CA into the hex field and get the same result, but the tool always displays hex output in uppercase. If you’re comparing against a system that prints lowercase hex, remember it’s the same value either way.
Ignoring leading zeros. 0202, 202, and 00202 are the same decimal number, and the same holds in every base: leading zeros never change the value, they’re just padding.
Expecting unlimited precision. The converter works reliably for integers within JavaScript’s safe integer range, roughly up to 2^53 − 1, about 9 quadrillion. That covers essentially every value you’d hit in normal programming or coursework, but numbers beyond that range start losing precision and need a dedicated big-integer library instead.
As a sanity check on round numbers, decimal 4096 (2^12) converts to binary 1000000000000, octal 10000, and hex 1000, a tidy reminder that every power of two produces a “1 followed by zeros” pattern in binary, and often a round-looking result in the other bases too.
Frequently asked questions
What is a number base or radix? It’s the count of unique digits a positional numeral system uses before rolling over to a new column. Base 10 has ten digits (0-9), base 2 has two (0-1), base 8 has eight (0-7), and base 16 has sixteen (0-9 plus A-F). The base also determines each column’s place value: powers of 10 in decimal, powers of 2 in binary, and so on.
Why do programmers use hexadecimal instead of just binary?
Because hex is a compact, human-readable stand-in for binary. Every hex digit corresponds to exactly 4 binary bits (a nibble), so a byte, which is 8 bits, always fits in exactly 2 hex digits. Writing 0xFF instead of 11111111 is shorter and far easier to scan, which is why hex dominates memory addresses, color codes, and byte-level debugging.
How do I convert binary to decimal by hand? Multiply each binary digit by its place value, a power of 2 counting from the right starting at 2^0, and add the results. For 11001010: 128 + 64 + 0 + 0 + 8 + 0 + 2 + 0 = 202. Skip the columns where the digit is 0 since they contribute nothing.
What’s the largest number this tool can convert accurately? Any integer within JavaScript’s safe integer range, up to 2^53 − 1 (about 9 quadrillion). Beyond that, floating-point precision starts to break down, so extremely large numbers need a specialized big-integer library instead.
Are negative numbers supported? Yes. Put a minus sign in front of the value in any field and all four bases update with the negative counterpart, using sign-magnitude representation (a sign plus the magnitude), not two’s complement. That distinction matters if you’re expecting the two’s complement bit pattern used in low-level programming.
Can I share the tool with my values already filled in? Yes. The URL updates automatically as you type, so copying it from the address bar or using the Share button sends along your exact inputs. Anyone who opens the link sees the same conversion you were looking at.