Skip to content
Calcapedia
Math

Number Base Converter

Convert whole numbers between binary, octal, decimal, hex and any base from 2 to 36. Long numbers stay exact, and an optional two's complement view shows how a computer stores them.

Level: Grades 6–8

Printable worksheet

Number Base Converter

Inputs

A whole number, optionally with a minus sign. Spaces, underscores and a matching 0b, 0o or 0x prefix are ignored.

Result

In binary

11111111

255 in decimal is 11111111 in binary

Decimal value
255
Digits in binary
8

See the step-by-step solution ↓

The same number in common bases
The same number in common bases
BaseValue
Binary (2)11111111
Octal (8)377
Decimal (10)255
Hexadecimal (16)FF

Step-by-step solution

  1. Divide by 2: quotient 127, remainder 1

    255 ÷ 2 = 127 remainder 1
  2. Divide by 2: quotient 63, remainder 1

    127 ÷ 2 = 63 remainder 1
  3. Divide by 2: quotient 31, remainder 1

    63 ÷ 2 = 31 remainder 1
  4. Divide by 2: quotient 15, remainder 1

    31 ÷ 2 = 15 remainder 1
  5. Divide by 2: quotient 7, remainder 1

    15 ÷ 2 = 7 remainder 1
  6. Divide by 2: quotient 3, remainder 1

    7 ÷ 2 = 3 remainder 1
  7. Divide by 2: quotient 1, remainder 1

    3 ÷ 2 = 1 remainder 1
  8. Divide by 2: quotient 0, remainder 1

    1 ÷ 2 = 0 remainder 1
  9. Read the remainders from the last one to the first to get the digits

    11111111

Test yourself

20 quick questions built from this calculator's formula: work out results, predict what happens when an input changes, and work backward from an answer. Every answer comes with the working.

What this calculator does

Turn a whole number from one number system into another, such as decimal to binary or hex, with the working shown. The base of a number system (also called the radix) is how many digit symbols it has before it carries into the next column. Everyday numbers are base 10. Computers work in base 2, called binary. Programmers often write binary more compactly in base 16, called hexadecimal or hex (digits 0–9 and A–F), or in base 8, called octal. Each column is worth the base multiplied by itself a certain number of times. So the same amount looks very different in each base: 255 in decimal is 11111111 in binary and FF in hex.

This converter changes whole numbers between any two bases from 2 to 36. It does exact whole-number math, so even numbers with dozens of digits convert without rounding. It accepts negative numbers with a minus sign. It can also show how a computer stores a value as an 8, 16, 32 or 64-bit two's complement pattern, the usual way computers store negative numbers. The steps show the column values or the repeated divisions behind the answer.

Where it's used

Why this math matters outside the classroom:

  • Computer bytes. Programmers write the byte 11111111 in binary as 255 in decimal and FF in hexadecimal.
  • Web colors. Designers read the color #FF8000 as red 255, green 128 and blue 0 by converting each hex pair to decimal.
  • Network addresses. Network technicians convert 192 to binary, 11000000, when working out subnet masks.
  • File permissions. Unix users set permissions with octal digits like 755, where 7 is binary 111 for read, write and execute.
  • Binary counting. Electronics students count in binary on four LEDs, where the pattern 1010 stands for decimal 10.

How to use it

  1. Type the number. You can include a minus sign, spaces or underscores between groups of digits, and a 0b, 0o or 0x prefix that matches the From base.
  2. Choose the base the number is written in and the base you want.
  3. If you like, pick a bit width to see the two's complement bit pattern.
  4. Read the result, the decimal value, and the table of the number in binary, octal, decimal and hex.

What the inputs mean

Number
A whole number written in the From base. Letters stand for digits above 9 (A = 10 up to Z = 35). Upper or lower case both work.
From base
The base the number is written in. Every digit must be smaller than the base.
To base
The base for the answer. Digits above 9 are shown as capital letters.
Two's complement view
Shows the bit pattern a computer would store for this value, in a signed whole-number slot of that width. Signed means it can hold negative numbers.

Formula and method

value = dₙ × bⁿ + … + d₁ × b¹ + d₀ × b⁰  (place values in base b)
to base B: divide by B, keep the remainder, repeat on the quotient until it is 0
digits in base B = remainders read from last to first
n-bit two's complement of a negative x = x + 2ⁿ
n-bit range: −2ⁿ⁻¹ to 2ⁿ − 1 (signed reading up to 2ⁿ⁻¹ − 1)

In the first line, b is the base the number is written in, and d₀, d₁ and so on are its digits, counted from the right starting at 0. A small raised number is a power: b² means b × b, and anything to the power 0 is 1. To read a number in any base, multiply each digit by its column value, a power of the base, and add them up. In the next lines, B is the base you want and the quotient is the whole-number answer of a division. Each division by B peels off the lowest digit as the remainder. The last remainder is the first digit of the answer.

In the last two lines, n is the number of bits (binary digits) and x is your number. People write negative numbers as a minus sign plus the size of the number, and the converter does the same. Computers usually store them in two's complement instead. A negative value x in n bits is stored as x + 2ⁿ, so −5 in 8 bits becomes 251, or 1111 1011. If the top bit of a pattern is 1, reading it as signed gives a negative number.

Worked example

Convert decimal 255 to binary.

  1. 255 ÷ 2 = 127 remainder 1; 127 ÷ 2 = 63 remainder 1; 63 ÷ 2 = 31 remainder 1; 31 ÷ 2 = 15 remainder 1.
  2. 15 ÷ 2 = 7 remainder 1; 7 ÷ 2 = 3 remainder 1; 3 ÷ 2 = 1 remainder 1; 1 ÷ 2 = 0 remainder 1.
  3. Read the remainders from last to first: 11111111.

Result: 255 in decimal is 11111111 in binary (and FF in hexadecimal).

Understanding the result

Each hex digit stands for exactly four binary digits, and each octal digit for exactly three. That's why hex and octal are popular shorthand for binary. If you group binary digits in fours from the right, you can read the hex straight off.

A two's complement pattern only means something once you know its width. 1111 1011 is −5 as a signed 8-bit number, but 251 unsigned (when it can't be negative).

Assumptions and limitations

  • Inputs are whole numbers. Digits above 9 are the letters A–Z.
  • Two's complement uses the standard rule: the pattern for x is x mod 2ⁿ, the remainder after dividing x by 2ⁿ.
  • It doesn't handle fractions (such as binary 0.101) or floating-point formats, the way computers store decimals.
  • Input is limited to 120 characters.
  • Long conversions show the first and last few division steps rather than every one.

Frequently asked questions

How do I convert binary to hexadecimal quickly?

Split the binary digits into groups of four from the right. Pad the leftmost group with zeros if it's short, then swap each group for its hex digit. 1010 1100 becomes AC. For octal, use groups of three instead.

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

They're prefixes many programming languages use to mark the base: 0x for hexadecimal, 0b for binary and 0o for octal. The converter ignores the prefix when it matches the From base.

How are negative numbers stored in binary?

Most computers use two's complement. To store −x in n bits, take 2ⁿ − x. In 8 bits, −1 is 11111111 and −128 is 10000000. Choose a bit width to see the pattern for your number.

Why does base 36 stop at Z?

Base 36 uses the ten digits plus the 26 letters of the alphabet, which is every single-character symbol available. Higher bases need digits made of several characters, or other symbols.

How this calculator is checked

Method: Positional notation (place values) and repeated division by the target base; standard two's complement representation. Exact BigInt arithmetic. The calculation is covered by automated tests with known reference values and edge cases. Last updated 2026-10-18. Found a problem? Tell us.

Embed this calculator

Put this Number Base Converter on your own website or blog for free. Paste this code where you want it to appear: