Number base converter with steps

Type a number, pick the base it is in and the base you want. The converter is exact even for huge numbers, spots repeating fractions and shows every step: repeated division, place values and the multiplication method.

e.g. 255, −42, 0.1, FF or 0x1F – prefixes 0x, 0b and 0o are fine
Non-terminating results are cut off after this many digits
Shows negative integers as a bit pattern; input in base 2, 8 or 16 is read as a bit pattern
Your inputs are saved in this browser only.

Result

Result
FF
Binary (base 2)
1111 1111
Octal (base 8)
377
Decimal (base 10)
255
Hexadecimal (base 16)
FF
Step-by-step working
  • Integer part: keep dividing by 16; each remainder is the next digit:
  • 255 ÷ 16 = 15 remainder 15 (F)
  • 15 ÷ 16 = 0 remainder 15 (F)
  • Read the remainders from bottom to top: FF₁₆

How it is calculated

How positional number systems work

In base b every digit is worth digit × bposition. In decimal, 255 means 2 × 10² + 5 × 10¹ + 5 × 10⁰. Binary uses only 0 and 1, octal 0–7 and hexadecimal 0–9 plus A–F (A = 10 … F = 15). Bases above 10 borrow letters, up to Z = 35 in base 36.

How to convert number bases

  1. Type the number, including digits after the point or a minus sign.
  2. Choose “From base” and “To base” (binary, octal, decimal, hexadecimal), optionally the max. digits after the point and two’s complement from 8 to 64 bits.
  3. Read the result in all four bases and the step-by-step working.
DecimalBinaryOctalHex
10101012A
15111117F
100110 010014464
2551111 1111377FF

Any base to decimal: add up place values

Multiply each digit by its power of the base and add: FF₁₆ = 15 × 16¹ + 15 × 16⁰ = 240 + 15 = 255. Digits after the point get negative powers: 0.1₂ = 1 × 2⁻¹ = 0.5.

Decimal to any base: repeated division

Divide by the target base again and again, writing down the remainders until you reach 0. Reading the remainders from bottom to top gives the answer. Example, 13 to binary:

Bottom to top: 13 = 1101₂.

Fractions: the multiplication method and repeating digits

Multiply the fractional part by the base; the whole-number part is the next digit, then carry on with what is left. 0.1 to binary: 0.1 × 2 = 0.2 → 0; 0.4 → 0; 0.8 → 0; 1.6 → 1; 1.2 → 1; then 0.4 comes back. Result: 0.1 = 0.0(0011)₂, a repeating fraction – which is why computers cannot store 0.1 exactly.

Whether an expansion terminates depends only on the reduced denominator: it terminates exactly when every prime factor of the denominator also divides the base. 1/2 terminates in binary (0.1₂); 1/10 does not, because 5 does not divide 2. The converter finds the period exactly, since it works with whole numbers (BigInt) rather than floating point.

Negative numbers and two’s complement

On paper a negative number just gets a minus sign: −255 = −FF₁₆. Processors store it in two’s complement: write the magnitude in binary, flip every bit, add 1. −1 in 8 bits: 0000 0001 → 1111 1110 → 1111 1111. With n bits the range is −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1, so 8 bits hold −128 to 127 and 128 overflows.

Other number formats: the Roman numeral converter, powers of two in the exponent calculator and huge values with the scientific notation converter.

Frequently asked questions

How do I convert decimal to binary?

Keep dividing by 2 and note each remainder until the quotient is 0. The remainders read from bottom to top are the binary number: 13 → 6 r1, 3 r0, 1 r1, 0 r1 → 1101.

How do I convert hex to decimal?

Multiply each digit by 16 to the power of its position (counting from 0 on the right) and add. A–F stand for 10–15: 2F₁₆ = 2 × 16 + 15 = 47.

Why does one hex digit match four binary digits?

Because 16 = 2⁴. Split a binary number into groups of four from the right and translate each group: 1111 1111 = F F = FF. Octal works the same way with groups of three, since 8 = 2³.

Why is 0.1 a repeating fraction in binary?

0.1 = 1/10, and 10 has the prime factor 5, which base 2 lacks. Such fractions never terminate in binary: 0.1 = 0.000110011…₂. 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: write the magnitude in binary, invert all bits and add 1. −1 in 8 bits becomes 1111 1111 (FF). An 8-bit value ranges from −128 to 127.

Which bases are supported?

Any base from 2 to 36. Beyond that we run out of symbols: 0–9 and A–Z make 36. Letters are not case-sensitive.

Sources and legal basis

As of:

Related tools