Number Base Converter (Binary, Hex, Octal)

Convert whole numbers between binary, octal, decimal and hexadecimal (or any base 2–36). Exact for very long values.

Whole numbers only. Spaces and underscores are ignored, a leading minus is allowed, and you may start with 0b, 0o or 0x when it matches the base below.

Results

Decimal (base 10)
255
Binary (base 2)
1111 1111
Octal (base 8)
377
Hexadecimal (base 16)
FF

How it’s calculated

In a positional number system each digit is worth the digit times a power of the base, and the digits are added up. In base 10 the number 255 means 2×10² + 5×10¹ + 5×10⁰. Binary uses base 2, octal base 8 and hexadecimal base 16 (the letters A–F stand for 10–15). Past base 16 the letters continue up to Z = 35, which is why 36 is the largest base here.

value = dₙ×bⁿ + … + d₂×b² + d₁×b¹ + d₀×b⁰ To write a number in base b: divide by b repeatedly; the remainders, read backwards, are the digits.

Example: the binary number 1111 1111 = 2⁷ + 2⁶ + … + 2⁰ = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. Dividing 255 by 16 gives 15 remainder 15, and 15 is F, so 255 = FF in hex. Because 8 and 16 are powers of 2, every hex digit is exactly 4 binary digits and every octal digit exactly 3.

This tool uses exact big-integer arithmetic, so even a 60-digit number converts without rounding. It handles whole numbers only, not fractions, and negative numbers are shown with a minus sign rather than as two's complement.

Frequently asked questions

How do I convert binary to decimal?

Choose "Binary", type the bits (spaces are fine) and read the decimal result. By hand, add the powers of two wherever there is a 1: 1011 = 8 + 2 + 1 = 11.

Why does the binary result have spaces?

Bits are grouped in fours from the right to make long values readable. Each group of four bits is exactly one hexadecimal digit.

What does the 0x or 0b prefix mean?

0x marks a hexadecimal number, 0b binary and 0o octal in many programming languages. You can include the prefix, but only the one that matches the base you chose.

Can it convert negative numbers or fractions?

Negative whole numbers are supported with a leading minus sign (the result is the signed value, not two's complement). Fractions are not supported.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator