Computers count in binary, programmers write memory addresses and colors in hexadecimal, and Unix file permissions are octal. This converter moves a number between any two bases from 2 to 36 — including the four everyday ones — and shows the arithmetic: place-value expansion into decimal, then repeated division into the target base.
How to use the number base converter
- Type the number. Use digits 0–9 and letters A–Z for digit values 10–35; letters are case-insensitive. A minus sign and one point (for fractions) are allowed, as are prefixes such as 0x, 0b and 0o.
- Choose the base it is written in and the base to convert to.
- Read the result on the tape, with the binary, octal, decimal and hexadecimal forms listed below it. Show the work walks through the conversion.
How base conversion works
A number in base b is a sum of digits times powers of b:
To convert the other way, divide by the new base repeatedly; the remainders are the digits from right to left. For a fractional part, multiply by the new base repeatedly; the whole-number parts are the digits from left to right.
Worked example
255 in decimal to binary. Divide by 2 and keep the remainders:
| Division | Quotient | Remainder |
|---|---|---|
| 255 ÷ 2 | 127 | 1 |
| 127 ÷ 2 | 63 | 1 |
| 63 ÷ 2 | 31 | 1 |
| 31 ÷ 2 | 15 | 1 |
| 15 ÷ 2 | 7 | 1 |
| 7 ÷ 2 | 3 | 1 |
| 3 ÷ 2 | 1 | 1 |
| 1 ÷ 2 | 0 | 1 |
Reading the remainders from bottom to top gives 11111111. The same number is 377 in octal and FF in hexadecimal: F = 15, and 15 × 16 + 15 = 255.
FF.8 in hex to decimal. The whole part is 255, and the fractional digit 8 is worth 8 ÷ 16 = 0.5, so FF.8₁₆ = 255.5.
Quick reference
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 1 0000 | 20 | 10 |
| 100 | 110 0100 | 144 | 64 |
| 255 | 1111 1111 | 377 | FF |
| 1,024 | 100 0000 0000 | 2000 | 400 |
| 65,535 | 1111 1111 1111 1111 | 177777 | FFFF |
Each hex digit stands for exactly four binary digits and each octal digit for three, which is why programmers use them as shorthand for binary.
Where you will meet other bases
- Hex colors. The web color #2F49D1 is three bytes: red 2F (47), green 49 (73) and blue D1 (209).
- File permissions. chmod 755 is octal for the binary permission bits 111 101 101: read-write-execute for the owner, read-execute for everyone else.
- Negative numbers. Processors store signed integers in two’s complement; −1 in 16 bits is FFFF.
- Short IDs. Base 36 (0–9 plus A–Z) packs large numbers into short, case-insensitive codes, as in some URL shorteners.
Unix timestamps are plain integers that sometimes appear in hexadecimal in logs and binary file formats; convert them to decimal here, then turn them into dates with the Unix timestamp converter. For bytes, kilobytes and gigabytes, use the data storage converter.
Frequently asked questions
How do you convert decimal to binary?
Divide the number by 2 repeatedly and record each remainder. Reading the remainders from the last to the first gives the binary digits. For 255: the remainders are all 1 eight times, so 255 in binary is 11111111.
How do you convert hexadecimal to decimal?
Multiply each digit by a power of 16 based on its position and add. A through F stand for 10 through 15. For example, 2F = 2 × 16 + 15 × 1 = 47.
Why do some fractions repeat in binary?
A fraction terminates in a base only if its denominator's prime factors divide that base. One tenth has a factor of 5 in its denominator, which 2 lacks, so 0.1 in binary is 0.0(0011), repeating forever. That is why 0.1 + 0.2 is not exactly 0.3 in most programming languages.
What is two's complement?
The standard way computers store negative integers. To get −x in n bits, subtract x from 2ⁿ. In 8 bits, −100 is 256 − 100 = 156, or 10011100 in binary. The calculator shows it for negative whole numbers.
How large a number can I convert?
Whole numbers of up to 4,000 digits, converted exactly with arbitrary-precision arithmetic. Fractional parts are converted digit by digit; repeating patterns are detected and shown in parentheses, and very long expansions are cut off after 40 digits.