Skip to content

Number Base Converter: Decimal, Hex, Binary, Octal

Convert numbers between any bases from 2 to 36 — decimal, binary, octal, hex — with fractions and two’s complement.

Your details

Digits above 9 are letters (A = 10 … Z = 35). A minus sign and a fraction point are allowed; spaces are ignored.

Only used when the number has a fraction. Digits beyond this are cut, not rounded.

Optional: show the integer as a fixed-width signed pattern, as stored in a computer register.

Results update as you type

Converted number

FF

Decimal (base 10)
255
Hexadecimal (base 16)
FF
Binary (base 2)
1111 1111
Octal (base 8)
377
Integer digits in the target base
2

Step-by-step solution
  1. Repeated division by 16 (remainders give the digits):
  2. 255 ÷ 16 = 15, remainder 15 → F
  3. 15 ÷ 16 = 0, remainder 15 → F
  4. Read the remainders from the last to the first: FF

Every number can be written in many bases. We count in base 10, computers store base 2, programmers read memory addresses and colours in base 16, and Unix file permissions are still written in base 8. This converter rewrites a number from any base between 2 and 36 into any other, including the most searched conversion of all: decimal to hexadecimal.

The conversion uses exact big-integer arithmetic, so a 200-digit decimal integer converts to binary without losing a single digit. Numbers with a fractional part work too: the calculator shows as many digits after the point as you ask for and tells you whether the result is exact, cut short, or repeating forever — and when it repeats, it shows the exact form with the repeating block in brackets.

Negative numbers are written with a minus sign. Pick a register width (8, 16, 32 or 64 bits) and you also get the two’s complement pattern a processor would store, plus the same bits read back as a signed integer. For small values the steps show the method you would use on paper: repeated division by the target base, then repeated multiplication for the fraction.

How to use this calculator

  1. Type the number to convert. Letters stand for digits above 9 (A = 10, B = 11 … F = 15 … Z = 35), in upper or lower case. Prefixes such as 0x (hex) or 0b (binary) are accepted when they match the source base.
  2. Choose the base it is written in (From base) and the base you want (To base). Decimal to hexadecimal is the default.
  3. If the number has a fraction, set how many fraction digits to show (16 by default).
  4. Optionally choose a two’s complement width to see the fixed-width signed pattern.
  5. Read the converted number, plus the decimal, hexadecimal, binary and octal forms side by side. Open the steps to follow the division method.

The formula

A numeral dn−1…d1d0.d−1d−2…d_{n-1}\dots d_1 d_0 . d_{-1} d_{-2}\dots in base bb has the value

N=∑idi b iN = \sum_{i} d_i \, b^{\,i}

Integer part to base tt: divide by tt repeatedly; the remainders, read from last to first, are the digits:

N=q0t+r0,q0=q1t+r1, …⇒N=(rk…r1r0)tN = q_0 t + r_0,\quad q_0 = q_1 t + r_1,\ \dots \quad\Rightarrow\quad N = (r_k \dots r_1 r_0)_t

Fraction to base tt: multiply the fraction by tt; the integer part of the product is the next digit, the fractional part is kept for the next round. A fraction p/qp/q in lowest terms terminates in base tt only when every prime factor of qq divides tt; otherwise its digits repeat.

Two’s complement on ww bits: a negative integer xx is stored as 2w+x2^{w} + x, which covers the range −2w−1-2^{w-1} to 2w−1−12^{w-1}-1.

Worked example

Decimal to hexadecimal: 2026. 2026÷16=1262026 \div 16 = 126 remainder 10 (A); 126÷16=7126 \div 16 = 7 remainder 14 (E); 7÷16=07 \div 16 = 0 remainder 7. Reading the remainders upwards gives 7EA. In binary, 2026 is 11111101010.

Hexadecimal to decimal: FF. 15×16+15=25515 \times 16 + 15 = 255, which is 1111 1111 in binary — the largest value of one byte.

A fraction that never ends: 0.1 in binary. 0.1×2=0.20.1 \times 2 = 0.2 → 0, 0.2×2=0.40.2 \times 2 = 0.4 → 0, 0.4×2=0.80.4 \times 2 = 0.8 → 0, 0.8×2=1.60.8 \times 2 = 1.6 → 1, 0.6×2=1.20.6 \times 2 = 1.2 → 1, then 0.2 comes back. To 12 digits: 0.000110011001…, exactly 0.0(0011). This is why 0.1 + 0.2 is not exactly 0.3 in most programming languages.

Two’s complement: −1 on 8 bits is 11111111, or FF in hex; −5 is 11111011.

Decimal to hexadecimal, quickly

Hexadecimal is popular because one hex digit is exactly four bits, so a byte is always two hex digits (00 to FF). To convert decimal to hexadecimal by hand, divide by 16 and write each remainder as a hex digit (10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F). To go from binary to hex, you do not even need decimal: split the bits into groups of four from the right and replace each group by its hex digit (1111 1101 = FD). Octal works the same way with groups of three bits.

Decimal Binary Octal Hex
10 1010 12 A
64 100 0000 100 40
255 1111 1111 377 FF
4096 1 0000 0000 0000 10000 1000

Where you meet each base

  • Base 2: bits, flags, network masks (255.255.255.0 is 24 ones followed by 8 zeros).
  • Base 8: Unix permissions — chmod 755 means rwx r-x r-x.
  • Base 16: colours (#FF8800), memory addresses, MAC addresses, Unicode code points (U+00E9 = é).
  • Base 36: short identifiers and URL shorteners, since 0–9 plus A–Z packs a large number into few characters.

To do arithmetic directly in binary, with carries shown, use the binary calculator.

Frequently asked questions

How do I convert decimal to hexadecimal?

Divide the number by 16, note the remainder, and repeat with the quotient until it reaches 0. Write the remainders from last to first, using A to F for 10 to 15. For example 255 gives remainders 15 and 15, so 255 = FF.

Why does 0.1 become a never-ending binary number?

A fraction terminates in a base only if its denominator’s prime factors divide that base. 0.1 is 1/10 and 10 contains the factor 5, which does not divide 2, so in binary the digits 0011 repeat forever. The calculator shows the cut-off digits and the exact repeating form.

What is two’s complement?

It is how computers store signed integers in a fixed number of bits: a negative number x is stored as 2^w + x. On 8 bits, −1 is 1111 1111 (FF) and −128 is 1000 0000. Choose a width to see the pattern, and the calculator warns you when the value does not fit.

Is there a size limit?

The input can have up to 600 digits. Integers are converted exactly with arbitrary-precision arithmetic, so there is no rounding, unlike converters that rely on ordinary 64-bit floating point.

Which letters are used for digits above 9?

A = 10, B = 11 and so on up to Z = 35, which is why the largest base is 36. Lowercase letters are accepted and the result is shown in uppercase.

Sources

Last updated:

More Conversion calculators

People also use