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
- 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.
- Choose the base it is written in (From base) and the base you want (To base). Decimal to hexadecimal is the default.
- If the number has a fraction, set how many fraction digits to show (16 by default).
- Optionally choose a two’s complement width to see the fixed-width signed pattern.
- 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 in base has the value
Integer part to base : divide by repeatedly; the remainders, read from last to first, are the digits:
Fraction to base : multiply the fraction by ; the integer part of the product is the next digit, the fractional part is kept for the next round. A fraction in lowest terms terminates in base only when every prime factor of divides ; otherwise its digits repeat.
Two’s complement on bits: a negative integer is stored as , which covers the range to .
Worked example
Decimal to hexadecimal: 2026. remainder 10 (A); remainder 14 (E); remainder 7. Reading the remainders upwards gives 7EA. In binary, 2026 is 11111101010.
Hexadecimal to decimal: FF. , which is 1111 1111 in binary — the largest value of one byte.
A fraction that never ends: 0.1 in binary. → 0, → 0, → 0, → 1, → 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
- Knuth, The Art of Computer Programming, vol. 2, §4.4 Radix conversion
- ECMAScript specification: Number::toString(x, radix), digits 0–9 and a–z
- Cornell University, Two’s complement (course notes)
Last updated: