Home › Math & Science › Hex Calculator
Hex Calculator
Convert numbers between hexadecimal, decimal, binary, and octal in one step. Type a value, tell the calculator which base it is in, and it shows all four representations instantly — with the place-value breakdown so you can see exactly how the conversion works.
How it works
Most of us count in decimal, base 10, because we have ten fingers. But a number does not have to be written in base 10 — the same quantity can be written in any base, and the choice is just a matter of how the digits are grouped. In decimal, each position is worth ten times the one to its right: the number 255 means 2 hundreds, 5 tens, and 5 ones. In hexadecimal, base 16, each position is worth sixteen times the one to its right. In binary, base 2, each position doubles. In octal, base 8, each position is worth eight times the previous one. The calculator above translates one writing of a number into the other three.
Hexadecimal needs sixteen symbols, and the ordinary digits only provide ten, so the letters A through F fill the gap: A stands for 10, B for 11, C for 12, D for 13, E for 14, and F for 15. That is why a value like FF is perfectly valid in hex — both digits are 15 — while a value containing G is not. Binary uses only 0 and 1, and octal uses only 0 through 7, so the digit 8 or 9 never appears in a binary or octal number. This calculator checks every character you type against the base you selected and warns you the moment a digit does not belong.
To convert by hand, work from the rightmost digit, which is always the ones place. Multiply each digit by its place value — the base raised to the power of its position, counting from zero on the right — and add everything up. For the hex number FF, the right F is worth 15 × 1 = 15 and the left F is worth 15 × 16 = 240, giving 255. For a longer number like 1A3, the places are 256, 16, and 1, so the value is 1 × 256 + 10 × 16 + 3 × 1 = 419. Going the other way, from decimal to another base, you divide by the base repeatedly and read the remainders backwards: 255 divided by 16 is 15 with remainder 15, and 15 divided by 16 is 0 with remainder 15, so the hex digits are F and F.
Binary, octal, and hex are closely related because their bases are all powers of two. One octal digit holds exactly three bits, and one hex digit holds exactly four bits, so converting between them is a matter of regrouping rather than arithmetic. To turn binary into hex, split the bits into groups of four starting from the right — padding the left with zeros if needed — and replace each group with its hex digit. The binary number 11111111 splits into 1111 and 1111, and each group is 15, so the hex is FF. To turn hex into binary, expand each hex digit back into four bits. The same trick works for octal with groups of three bits, which is why programmers move between these bases so freely.
Hex shows up wherever computers meet humans. Colors on the web are written as six hex digits, two each for red, green, and blue — FF5733 is a bright orange-red. Memory addresses, error codes, and the identifiers inside files are usually shown in hex because eight hex digits carry the same information as thirty-two binary digits in a quarter of the space. Even a familiar decimal number like 255 is really the hex FF, the largest value one byte can hold. Knowing how to read hex turns those cryptic strings into numbers you can actually picture.
Worked example
Convert the hex number FF to decimal, binary, and octal.
Step 1: Read the digits — F and F, each worth 15.
Step 2: Multiply by place values — the left F sits in the 16s place, so 15 × 16 = 240; the right F sits in the 1s place, so 15 × 1 = 15.
Step 3: Add — 240 + 15 = 255 in decimal.
Step 4: Convert 255 to binary by repeated division by 2 — the remainders, read backwards, are 11111111.
Step 5: Convert 255 to octal by repeated division by 8 — 255 ÷ 8 = 31 remainder 7, 31 ÷ 8 = 3 remainder 7, 3 ÷ 8 = 0 remainder 3, so the digits are 377.
The calculator gives the same answers: FF in hex = 255 in decimal = 11111111 in binary = 377 in octal. Try the other direction too: enter 42 as a decimal and you get 2A in hex, 101010 in binary, and 52 in octal. Or enter 1010 as binary and you get 10 in decimal, A in hex, and 12 in octal. Change the base selector and the value field to explore any number you like.
FAQ
What is hexadecimal?
Hexadecimal is a base-16 number system. It uses the digits 0 to 9 plus the letters A to F, where A stands for 10, B for 11, C for 12, D for 13, E for 14, and F for 15. Each position is worth 16 times the one to its right, just as each decimal position is worth 10 times the one to its right.
Why do programmers use hex?
Hex is a compact way to write binary. One hex digit stands for exactly four bits, so a byte is two hex digits and a 32-bit value is eight. A color like FF5733 is six hex digits instead of 24 binary digits, and a memory address is far easier to read in hex than in binary.
How do I convert hex to decimal by hand?
Multiply each hex digit by its place value and add the results. In FF, the left F is worth 15 times 16, which is 240, and the right F is worth 15 times 1, which is 15, so FF equals 255. For longer numbers, keep going: the next place to the left is worth 256, then 4096.
What letters are allowed in hex?
Only the letters A through F, in upper or lower case, plus the digits 0 through 9. The letter G is not a hex digit, and neither are H through Z. This calculator will warn you if you type a character that is not valid for the base you selected.
How are binary, octal, and hex related?
They are all powers of two, so they convert into each other in fixed groups. One octal digit is three bits, and one hex digit is four bits. To turn binary into hex, split the bits into groups of four from the right and replace each group with its hex digit; to go the other way, expand each hex digit into four bits.