Number Base Converter

Number systems are part of computer science, digital electronics and networking courses. Enter a whole number in binary, octal, decimal or hexadecimal to see it in all four bases along with the conversion method.

How it is calculated

Type the number.

Select the base it is written in.

Read the value in all four bases.

Formula

To decimal: N = Σ digitᵢ × base^position

Decimal to base b: Divide by b repeatedly; remainders read upward

What is the Number Base Converter?

The number base converter takes a whole number written in binary (base 2), octal (base 8), decimal (base 10) or hexadecimal (base 16) and shows it in all four. It writes out the place-value expansion used to convert to decimal and the repeated division by 2 used to reach binary.

Computers store everything in binary, but long strings of 0s and 1s are hard for people to read, so programmers and network engineers use hexadecimal as a compact shorthand: each hex digit stands for exactly four bits. You meet these conversions in Class 11 computer science, digital electronics, IP addressing and subnetting, MAC addresses, colour codes in web design such as #FF8800, and memory dumps. The converter also rejects digits that do not exist in the chosen base, such as 2 in binary or G in hexadecimal.

How to calculate it by hand

1. To convert any base b to decimal, number the digit positions from 0 on the right. Multiply each digit by b raised to its position and add: N = Σ digit × b^position.

2. For hexadecimal, read A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15 before multiplying.

3. To convert decimal to base b, divide by b repeatedly, writing down each remainder, until the quotient is 0.

4. Read the remainders from the last one to the first. That is the number in base b.

5. To convert binary to octal, group the bits in threes from the right; to convert binary to hex, group in fours. Replace each group by its single digit.

6. Check by converting the answer back to decimal.

Place value in any base

In decimal, 472 means 4 × 100 + 7 × 10 + 2 × 1, powers of 10 from the right. Any base b works the same way with powers of b, and needs exactly b different digits, from 0 up to b − 1. Binary uses powers of 2, so 1011₂ = 8 + 0 + 2 + 1 = 11. Hexadecimal needs sixteen digits, so the letters A to F stand for ten to fifteen. The value of a number never changes, only the way it is written.

Why repeated division gives the digits

Dividing N by b leaves a remainder between 0 and b − 1, which is exactly the rightmost digit in base b, because every other digit contributes a multiple of b. The quotient is the number with that last digit removed. Repeating the division peels off the next digit each time, from right to left. That is why the remainders must be read upward, from the last division to the first, to write the answer.

Why octal and hex group binary neatly

Since 8 = 2³, every octal digit corresponds to exactly three binary digits, and since 16 = 2⁴, every hex digit corresponds to exactly four. So a byte of 8 bits is always two hex digits, from 00 to FF, which is 0 to 255 in decimal. This is why IPv4 octets, MAC addresses and colour codes are written in hex. This converter handles non-negative whole numbers only; fractions and negative numbers, such as two's complement, need other methods.

Worked example, step by step

Vikram, a networking student, sees the hex value C0A8 at the start of an address field in a packet capture and wants its decimal and binary forms to identify the octets.

Convert to decimal (place values): 12×16^3 + 0×16^2 + 10×16^1 + 8×16^0 = 49320

Decimal to binary (repeated division by 2, read remainders upward): 49320 ÷ 2 = 24660 r 0 24660 ÷ 2 = 12330 r 0 12330 ÷ 2 = 6165 r 0 6165 ÷ 2 = 3082 r 1 3082 ÷ 2 = 1541 r 0 1541 ÷ 2 = 770 r 1 770 ÷ 2 = 385 r 0 385 ÷ 2 = 192 r 1 192 ÷ 2 = 96 r 0 96 ÷ 2 = 48 r 0 48 ÷ 2 = 24 r 0 24 ÷ 2 = 12 r 0 12 ÷ 2 = 6 r 0 6 ÷ 2 = 3 r 0 3 ÷ 2 = 1 r 1 1 ÷ 2 = 0 r 1 = 1100000010101000₂

Octal and hexadecimal: Group binary digits in threes → 140250₈; in fours → C0A8₁₆

Answer: Decimal 49320; Binary 1100000010101000; Octal 140250

Common mistakes to avoid

Reading the remainders from top to bottom instead of bottom to top.

Numbering place values from the left instead of the right, or starting at 1 instead of 0.

Grouping binary digits from the left when converting to octal or hex, instead of from the right.

Choosing the wrong source base, such as treating 101 as binary when it was meant as decimal.

Forgetting that A to F mean 10 to 15, and treating them as separate digits like 1 and 0.

Where it is used

Converting IP address octets and subnet masks between decimal and binary for subnetting.

Reading MAC addresses, memory addresses and error codes shown in hexadecimal.

Translating web colour codes such as #1E90FF into red, green and blue values.

Checking Class 11 and 12 computer science and digital electronics exercises.

Setting file permissions on Linux, which are written in octal such as 755.

Frequently asked questions

Why are there letters in hexadecimal?

Base 16 needs sixteen digits, so A–F represent 10–15.

Does it convert fractions?

No, only whole numbers.