Skip to content

Number Base Converter

Type a number in any base from 2 to 36 and see it in binary, octal, decimal and hexadecimal at once, plus any other base you pick. Whole numbers of any length up to 1,024 bits convert exactly, fractions show where the digits repeat, and a two’s-complement view gives the bit pattern a computer stores for a signed 8-, 16-, 32- or 64-bit integer. For byte and bit units rather than digits, use the data storage converter.

Digits 0–9 and letters A–Z for bases above 10 (upper or lower case). A leading minus, one point for a fraction, and 0x / 0b / 0o prefixes are fine; spaces or underscores between digit groups are ignored.

Result

In Binary (base 2)

111 1110 1010

Binary (base 2)
111 1110 1010
Octal (base 8)
3 752
Decimal (base 10)
2 026
Hexadecimal (base 16)
7 EA

Two’s complement

16-bit patternPositive: the binary digits padded with zeros; the leftmost (sign) bit is 0.
0000 0111 1110 1010
Same bits in hex
07 EA
Signed range
-32,768 to 32,767
Show the working
  1. Divide by 2 again and again; the remainders, read from last to first, are the digits2,026 ÷ 2 = 1,013 r 0; 1,013 ÷ 2 = 506 r 1; …; 1 ÷ 2 = 0 r 1 = 111 1110 1010

Whole numbers are converted exactly with integer arithmetic, however many digits they have. Digits above 9 are the letters A = 10 to Z = 35.

Repeated division by 2

Repeated division by 2. Scroll sideways to see all columns.
StepNumberQuotientRemainder (digit)
12,0261,0130
21,0135061
35062530
42531261
5126630
663311
731151
81571
9731
10311
11101

How to convert between number bases

A base (or radix) is how many different digits a number system uses. Decimal uses ten (0–9); binary two (0 and 1); octal eight (0–7); hexadecimal sixteen, with the letters A to F standing for 10 to 15. Bases up to 36 continue through the alphabet to Z = 35.

  1. Type the number. Upper- and lower-case letters are the same; 0x, 0b and 0o prefixes are accepted.
  2. Choose the base it is written in, and the base you want. Choose “Other base” for anything from 2 to 36.
  3. Read the answer, and the same value in the four common bases. Open the working to see the place-value sum and the repeated divisions; the full division table is under the calculator.

Negative numbers keep their minus sign in every base. To see how a computer actually stores a negative integer, pick a two’s-complement size. For very large or small decimal values, the scientific notation calculator is the better tool; for kilobytes and gibibytes, use the data storage converter.

The method

Any base to decimal. Each digit is worth its value times the base raised to the power of its position, counting from 0 at the right of the point (and −1, −2, … after it):

N = dₖ × bᵏ + … + d₁ × b¹ + d₀ × b⁰ + d₋₁ × b⁻¹ + …

b
the base the number is written in
dᵢ
the digit in position i, as a value from 0 to b − 1

Decimal to another base, whole part. Divide by the new base and write down the remainder; divide the quotient again, and repeat until the quotient is 0. The remainders are the digits, the last one first.

Fractional part. Multiply the fraction by the new base. The whole part of the product is the next digit; keep the fractional part and repeat. The process stops when the fraction becomes 0. If a fraction comes back that was seen before, the digits from that point repeat forever: the calculator marks them with a line on top. It stops after 40 digits if neither happens.

Two’s complement. An n-bit signed integer stores a value v ≥ 0 as its ordinary binary digits and a negative value as 2ⁿ + v (that is, 2ⁿ − |v|). The leftmost bit therefore shows the sign, and the range is −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1.

Worked example

Convert 2026 from decimal to binary.

  1. 2026 ÷ 2 = 1013 remainder 0; 1013 ÷ 2 = 506 r 1; 506 ÷ 2 = 253 r 0; 253 ÷ 2 = 126 r 1.
  2. 126 ÷ 2 = 63 r 0; 63 ÷ 2 = 31 r 1; 31 ÷ 2 = 15 r 1; 15 ÷ 2 = 7 r 1; 7 ÷ 2 = 3 r 1; 3 ÷ 2 = 1 r 1; 1 ÷ 2 = 0 r 1.
  3. Reading the remainders from last to first gives 11111101010, or 111 1110 1010 grouped in fours.
  4. Check: 1024 + 512 + 256 + 128 + 64 + 32 + 8 + 2 = 2026.

The same number is 3752 in octal (3 × 512 + 7 × 64 + 5 × 8 + 2) and 7EA in hexadecimal (7 × 256 + 14 × 16 + 10). In 16-bit two’s complement it is 0000 0111 1110 1010 (07EA); −2026 is stored as 2¹⁶ − 2026 = 63,510, which is 1111 1000 0001 0110 (F816).

A fraction: 255.625 is FF.A in hexadecimal and 11111111.101 in binary (0.625 × 2 = 1.25 → 1, 0.25 × 2 = 0.5 → 0, 0.5 × 2 = 1 → 1). But 0.1 in decimal becomes 0.0 0011 0011 0011… in binary, with the block 0011 repeating forever.

Things to know

  • Shortcuts between binary, octal and hex. One hex digit is exactly four bits (a nibble) and one octal digit exactly three, so you can convert by replacing groups: 0111 1110 1010 is 7 E A.
  • Why 0.1 + 0.2 isn’t exactly 0.3 in software. Decimal fractions such as 0.1 repeat forever in binary, so a computer that stores them in binary floating point keeps only an approximation.
  • Sign and magnitude vs. two’s complement. Writing −FF is the mathematical way to show a negative hex number. Inside a computer, −1 in 8 bits is the pattern FF, and the same bits read as unsigned mean 255: the width decides the meaning.
  • Limits. Whole parts up to 2¹⁰²⁴ − 1 and up to 64 digits after the point are accepted; output fractions stop after 40 digits. Related: prime factorization works on the same whole numbers, and the scientific calculator handles general arithmetic.

Why letters stop at Z

Ten digits plus 26 letters make 36 symbols, so 36 is the largest base that can be written with ordinary digits and letters. That is why programming languages that convert with a radix accept bases 2 to 36.

Frequently asked questions

How do I convert binary to decimal?

Multiply each bit by 2 raised to the power of its position, counting from 0 at the right, and add the results. For 1101 that is 8 + 4 + 0 + 1 = 13. Only the positions with a 1 contribute.

How do I convert decimal to hexadecimal?

Divide by 16 repeatedly and note the remainders, writing 10 to 15 as A to F; read them from the last to the first. 2026 ÷ 16 = 126 r 10 (A), 126 ÷ 16 = 7 r 14 (E), 7 ÷ 16 = 0 r 7, so 2026 is 7EA.

What is two’s complement?

It is the way computers store signed integers. Positive numbers are stored as plain binary; a negative number −x is stored in n bits as 2 to the power n minus x. In 8 bits −1 is 11111111 and −128 is 10000000, and the range is −128 to 127.

Why does 0.1 never end in binary?

A fraction ends in a base only if its denominator, in lowest terms, is made of the prime factors of that base. 0.1 is 1/10 and 10 contains the factor 5, which 2 does not have, so in binary the digits 0011 repeat forever after 0.0.

What do the 0x, 0b and 0o prefixes mean?

They are how many programming languages mark the base of a number: 0x for hexadecimal (0xFF = 255), 0b for binary (0b1010 = 10) and 0o for octal (0o17 = 15). The converter accepts them when the matching base is selected.

Last reviewed September 19, 2026