Home›Math›Decimal to Hexadecimal

How to Convert Decimal to Hexadecimal (and Octal)

Hexadecimal is divide by 16 with remainders 0 to 15, where 10 to 15 are written A to F. Octal is the same method with divisor 8. This guide works both conversions, shows the bit-grouping shortcut, and explains when each base is actually used.

14 min readUpdated October 2026Decimal Calculator

Hexadecimal and octal are converted exactly like binary, with a different divisor. Divide by 16 for hexadecimal and record each remainder; divide by 8 for octal. The only new idea is what to write when a remainder is bigger than 9: in hexadecimal, 10 is A, 11 is B, 12 is C, 13 is D, 14 is E, and 15 is F. Everything else — the stopping rule, the backwards reading, the expansion check — is the same method you already know from binary, and the shortcut of grouping binary bits makes large conversions fast.

Key takeaways
  • Hexadecimal conversion is divide by 16 and read the remainders backwards, writing A to F for remainders 10 to 15. Octal is divide by 8 and read backwards, with remainders 0 to 7 only.
  • Four binary bits make exactly one hexadecimal digit and three binary bits make exactly one octal digit, so converting through binary by grouping is often faster than dividing, and it never needs the letter mapping until the last step.
  • Check any answer by expansion: multiply each digit by its place value, 1, 16, 256 for hexadecimal or 1, 8, 64 for octal, and add. The total must be the starting number.

Hexadecimal: divide by 16, read backwards

Hexadecimal is base 16. Its sixteen digits are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Each place is worth sixteen times the place to its right: from the right, the places are 1, 16, 256, 4,096, 65,536. A hexadecimal number such as 2F means 2 sixteens plus 15 ones, which is 47 in decimal. The digit letters are not decoration; they are necessary, because a base-16 system needs sixteen distinct single symbols, and the digits 0 to 9 only supply ten. The letters supply the other six, and every hexadecimal digit is exactly one symbol, which is what keeps the place system working.

The conversion method is the divide-by-2 method with 2 replaced by 16. Divide the decimal number by 16, record the quotient and the remainder. The remainder, which is between 0 and 15, is the rightmost hexadecimal digit; write it as a letter if it is 10 or more. Divide the quotient by 16, record the next remainder, and continue until the quotient is 0. Read the remainders backwards. Convert 47: 47 divided by 16 is quotient 2, remainder 15, which is F. 2 divided by 16 is quotient 0, remainder 2. Read backwards: 2F. Check: 2 times 16 plus 15 is 47. The method is identical in structure to binary conversion, and the same two guards apply: stop only at quotient 0, and verify by expansion.

The size of the divisor is what makes hexadecimal compact. A number that needs 8 binary bits needs only 2 hexadecimal digits, because each hexadecimal digit carries 4 bits of information. That compactness is the entire reason hexadecimal exists in computing: it is a short way of writing binary, not a separate kind of number. A memory address written as 0xFF is the byte 11111111, and the 0x prefix is simply the convention that says the digits that follow are hexadecimal. Without that prefix, FF could be read as a word, and 10 could be ten or sixteen, so always state the base when the context does not make it obvious.

Worked example: 255 and 4,096 in hexadecimal

Convert 255. Divide 255 by 16: quotient 15, remainder 15. Both numbers need letters: 15 is F, in both positions. Divide 15 by 16: quotient 0, remainder 15, which is F. Read backwards: FF. Check: 15 times 16 plus 15 is 240 plus 15, which is 255. FF is the largest two-digit hexadecimal number, just as 99 is the largest two-digit decimal number and 11111111 is the largest 8-bit binary number. The three are the same value in three bases, and recognising the pattern across bases is the fastest way to build fluency: the largest number with a given count of digits is always all of the largest digit.

Convert 4,096. Divide by 16: quotient 256, remainder 0. Divide 256 by 16: quotient 16, remainder 0. Divide 16 by 16: quotient 1, remainder 0. Divide 1 by 16: quotient 0, remainder 1. Read backwards: 1000 in hexadecimal, which is 1 times 4,096. That is the hexadecimal 1000, not the decimal 1000; in decimal, hexadecimal 1000 is 4,096. The confusion between the written digits and the value is the reason base prefixes matter: 0x1000 is 4,096, while 1000 without a prefix is one thousand. In conversation, say hex one-zero-zero-zero to keep the distinction audible.

1,000 in hexadecimal: 3 times 256 plus 14 times 16 plus 8 equals 1,000. Octal and binary are included for the grouping shortcut below.

DecimalHexadecimalOctalBinary
10A121010
15F171111
16102010000
472F57101111
255FF37711111111
1,0003E817501111101000

The letters A to F, and why they exist

The letters are values, not abbreviations. A is ten, and it behaves as ten in every calculation. In the expansion of 2F, the F contributes 15, not 6, and in the expansion of A3, the A contributes 10 sixteens, which is 160, plus 3, giving 163. Forgetting the letter values is the most common hexadecimal error: treating F as if it were worth 6, or reading AB as if it were a word. A useful drill is to convert the letters back and forth until they are automatic: A is 10, B is 11, C is 12, D is 13, E is 14, F is 15. The sequence runs alphabetically and numerically together, which is why it is easy once learned and treacherous while it is being learned.

Case does not matter: a and A are the same digit, and f and F are the same digit. Code and calculators vary in which they print, and mixed case in one number is legal even if it looks untidy. What matters is that each digit is one symbol. Writing 10 where you mean A is not a style choice; it is two digits, a 1 in one place and a 0 in the next, and it changes the value. That is also why hexadecimal never uses G: G would be 16, which is not a digit in base 16 but the start of the next place. If a conversion produces a remainder of 16, the division was done wrong, because dividing by 16 can never leave a remainder of 16.

Octal: divide by 8, read backwards

Octal is base 8, with digits 0 to 7 and places 1, 8, 64, 512, 4,096. The conversion is divide by 8, record remainders, read backwards. Convert 47: 47 divided by 8 is quotient 5, remainder 7. 5 divided by 8 is quotient 0, remainder 5. Read backwards: 57. Check: 5 times 8 plus 7 is 47. Octal needs no letters, because eight digits fit inside the decimal digits, and its remainders are never larger than 7. That simplicity is its charm and its limitation: octal is less compact than hexadecimal, needing three digits where hexadecimal needs two for the same byte, which is why hexadecimal displaced it in most computing uses while octal survives in file permissions on Unix-like systems, where three permission bits map neatly to one octal digit.

Convert a larger number, 1,000, in octal. Divide by 8: quotient 125, remainder 0. Divide 125 by 8: quotient 15, remainder 5. Divide 15 by 8: quotient 1, remainder 7. Divide 1 by 8: quotient 0, remainder 1. Read backwards: 1750. Check: 1 times 512 plus 7 times 64 plus 5 times 8 plus 0 is 512 + 448 + 40 = 1,000. Notice the digit 8 never appears in an octal answer. If your octal conversion contains an 8 or a 9, it is wrong by definition, and the error is usually a remainder taken from a division by 10 rather than by 8. The digit test — no digit at or above the base — is a one-second check that applies to every base: binary answers contain only 0 and 1, octal answers only 0 to 7, and decimal answers only 0 to 9.

The grouping shortcut through binary

The fastest route between bases is through binary, because 16 is 2 to the power of 4 and 8 is 2 to the power of 3. Four binary bits make one hexadecimal digit, and three binary bits make one octal digit, exactly, with no division and no remainders. To convert binary to hexadecimal, split the bits into groups of four starting from the right, pad the leftmost group with leading zeros if it is short, and replace each group with its hexadecimal digit. 101111 splits as 10 and 1111, padded to 0010 and 1111, which are 2 and F: 2F, which matches the division result for 47 above. To convert hexadecimal to binary, reverse the process: replace each digit with its four bits. F becomes 1111, 2 becomes 0010, and the pair is 101111, dropping the leading zeros to 101111.

Octal grouping works the same way with groups of three. 101111 splits from the right as 101 and 111, which are 5 and 7: 57, matching the division result. Grouping direction matters: always group from the right, from the least important bit, and pad on the left. Grouping from the left gives the wrong answer, because the leftmost group would then be short in the wrong place. To convert decimal to hexadecimal by grouping, first convert to binary by dividing by 2, then group. That is two steps, but each step is easy, and for large numbers it is faster and less error-prone than dividing by 16 with letter remainders, because the only letters appear at the very end, when groups are read off.

Group from the right. Pad the leftmost group with zeros.

4-bit groupHex digit3-bit groupOctal digit
000000000
000110011
001020102
010151015
1010A1106
1111F1117

Fractions in hexadecimal and octal

Fractions convert by the same multiply method as binary, with the base as the multiplier. Multiply the fraction by 16 for hexadecimal, record the whole part as the next digit, and carry the fractional part forward. Convert 0.5: doubling by 16 gives 8.0, so the first hexadecimal fraction digit is 8 and the process stops: 0.8 in hexadecimal, which checks as 8 sixteenths, one half. Convert 0.25: 0.25 times 16 is 4.0, so the answer is 0.4 in hexadecimal, which is 4 sixteenths, one quarter. Fractions that terminate in binary also terminate in hexadecimal and octal, because the denominators are powers of 2, and fractions that repeat in binary, such as 0.1, repeat in hexadecimal too: 0.1 in decimal is the repeating hexadecimal 0.1999, which is worth knowing because it is the same storage approximation seen in binary, written more compactly.

For octal fractions, multiply by 8. Convert 0.5: 0.5 times 8 is 4.0, so the answer is 0.4 in octal, which is 4 eighths, one half. Convert 0.75: 0.75 times 8 is 6.0, so the answer is 0.6 in octal. As with binary fractions, read the digits forwards, in the order produced, because the first multiplication finds the most important fraction place. Mixed numbers convert part by part: 47.5 is 2F from the whole part and .8 from the fraction part, giving 2F.8 in hexadecimal. The point separates the two methods, division on the left and multiplication on the right, and keeping the two sides in separate columns until both are finished prevents the commonest fraction error, which is applying the wrong method to the wrong side.

When each base is actually used

Hexadecimal is the working base of computing. Memory addresses, colour codes, error codes, and machine-code listings are written in hexadecimal because it is binary made readable: the colour code FF0000 is three bytes, red 255, green 0, blue 0, and the grouping makes that structure visible at a glance. Web colours, Unicode code points, and cryptographic hashes are all conventionally hexadecimal. Octal survives in one prominent place: Unix file permissions, where read, write, and execute are three bits, and a permission such as 755 is three octal digits, one per owner, group, and others. Binary itself is used in teaching, in bit-level documentation, and wherever the individual bits matter, such as flags and masks.

Outside computing, other bases are rare, and decimal remains the base of everyday life precisely because it is the base people count in. The practical skill is therefore translation: read a hexadecimal value, expand it to check it, group it to see the bits, and convert it back without a calculator when the numbers are small. The Decimal Calculator handles the decimal arithmetic exactly; these conversions handle the representation. Neither replaces the other, and the habit of stating the base — 0x for hexadecimal in code, a subscript or a label in writing — prevents the ambiguity that makes 10 mean three different values in three bases.

Mistakes: letter slips, grouping direction, and place values

The letter slip is first: writing the remainder 12 as 2, or reading C as 3. Write the remainder and its letter together on each row, 12 (C), until the mapping is automatic, and check by expansion with the letter values, not the letters. Second, grouping from the left instead of the right, which misaligns every group. Always start at the binary point, or at the rightmost bit for whole numbers, and pad on the left only. Third, expanding with decimal place values: the places in hexadecimal are 1, 16, 256, not 1, 10, 100, and expanding 2F as 2 times 10 plus 15 gives 35, not 47. Write the place values above the digits before multiplying, every time, until the base-16 places are as familiar as the base-10 ones.

Fourth, accepting a digit that the base forbids: an 8 in an octal answer, a G in a hexadecimal answer, or a remainder of 16 from a division by 16. Any of these proves an error on the spot, with no expansion needed. Fifth, dropping the final remainder: the division that reaches quotient 0 still produces a digit, and it is the leftmost digit of the answer. Omitting it divides the value by the base. The guards are cheap and complete: digit test, backwards reading, expansion check. Use all three, and hexadecimal and octal conversions become as routine as the binary ones they generalise.

Frequently asked questions

How do you convert decimal to hexadecimal step by step?

Divide the decimal number by 16 and write down the remainder, then divide the quotient by 16 and write that remainder, and continue until the quotient is 0. Write remainders of 10 to 15 as A to F. Read the remainders backwards, from the last division to the first. For 47, the remainders are 15 and 2, giving 2F. Check by expansion: 2 times 16 plus 15 equals 47.

What is 255 in hexadecimal and octal?

255 is FF in hexadecimal and 377 in octal. In hexadecimal, 255 divided by 16 gives quotient 15 remainder 15, and 15 divided by 16 gives quotient 0 remainder 15, so the digits are F and F. In octal, dividing by 8 repeatedly gives remainders 7, 7, and 3, read backwards as 377. Check octal by expansion: 3 times 64 plus 7 times 8 plus 7 equals 255.

Why does hexadecimal use letters?

Hexadecimal needs sixteen distinct single symbols, one for each value from 0 to 15, and the decimal digits supply only ten. The letters A to F supply the other six, with A worth 10, B worth 11, C worth 12, D worth 13, E worth 14, and F worth 15. Each letter is one digit with a numeric value, and it must be expanded at that value when checking an answer.

How do you convert binary to hexadecimal quickly?

Group the binary bits into fours starting from the right, pad the leftmost group with leading zeros, and replace each group with its hexadecimal digit. For example, 101111 groups as 0010 and 1111, which are 2 and F, giving 2F. For octal, group into threes instead: 101111 groups as 101 and 111, which are 5 and 7, giving 57. Grouping works because 16 is 2 to the power of 4 and 8 is 2 to the power of 3.

What is the difference between hexadecimal and octal?

Hexadecimal is base 16, with digits 0 to 9 and A to F and place values 1, 16, 256, while octal is base 8, with digits 0 to 7 and place values 1, 8, 64. Hexadecimal is more compact, needing two digits per byte against three for octal, and it is the standard base for memory addresses and colour codes. Octal survives mainly in Unix file permissions, where three bits map to one octal digit.

Can decimal fractions be converted to hexadecimal exactly?

Some can and some cannot. Fractions whose denominator is a power of 2, such as one half or one quarter, terminate: 0.5 is 0.8 in hexadecimal and 0.4 in octal. Fractions such as 0.1 repeat forever in hexadecimal, as they do in binary, because 0.1 is not a sum of sixteenths that ends. Convert fractions by multiplying by the base and recording the whole part at each step, reading the digits forwards in the order they are produced.

Try it on the calculator

Use the Decimal Calculator for the decimal arithmetic, and the methods on this page for the representation. Convert in one base, check in another, and the two must agree.

Open the Decimal Calculator →
Related guides

Similar Posts