Short answer: a positional numeral is a sum of digits multiplied by powers of its base. To reach decimal, evaluate those powers or repeatedly multiply a running total by the base. To leave decimal, divide by the target base and read remainders upward. Binary converts directly to hex in four-bit groups and to octal in three-bit groups. Sign, fixed width, and text encoding remain separate concerns.

Start with the radix and digit positions

A numeral system's base, also called its radix, determines the available digit values and each position's weight. In base b, the rightmost whole-number digit has weight b0, the next has weight b1, then b2. A spelling without its base is ambiguous: 10 means two in binary, eight in octal, ten in decimal, and sixteen in hexadecimal.

SystemBaseDigitsRelationship
Binary20–1One digit is one bit
Octal80–7One digit maps to three bits
Decimal100–9Common human notation
Hexadecimal160–9, A–FOne digit maps to four bits

Hex letters are digit values: A is ten through F as fifteen. Letter case does not change the value. Prefixes such as 0b, 0o, and 0x can label a base in programming contexts, but they are syntax rather than part of the mathematical value.

Convert binary to decimal with positional weights

For binary 101101, label positions from right to left and add the powers whose bit is one:

Binary 101101 to decimal
1×2⁵ + 0×2⁴ + 1×2³ + 1×2² + 0×2¹ + 1×2⁰
= 32 + 0 + 8 + 4 + 0 + 1
= 45

A left-to-right method avoids writing every power. Begin at zero; for each bit, double the running total and add that bit. Processing 101101 yields totals 1, 2, 5, 11, 22, and 45. This is Horner's method specialized to base 2. In any base, multiply the current total by the base and add the next digit.

Convert decimal to binary with repeated division

To convert nonnegative decimal 45 to binary, repeatedly divide by two and record each remainder. Continue with the quotient until it reaches zero:

Decimal 45 divided by two
45 ÷ 2 = 22 remainder 1
22 ÷ 2 = 11 remainder 0
11 ÷ 2 =  5 remainder 1
 5 ÷ 2 =  2 remainder 1
 2 ÷ 2 =  1 remainder 0
 1 ÷ 2 =  0 remainder 1

Read remainders upward: 101101

The first remainder is the least significant bit, so reading downward reverses the number. Convert back with positional weights as an independent check. For zero, emit the digit 0; an ordinary repeated-division loop otherwise has no remainder to record.

Convert binary and hexadecimal in four-bit groups

Because 16 equals 24, split a whole-number binary string into groups of four from the right. Pad only the leftmost incomplete group for lookup. Binary 1011110011 becomes 0010 1111 0011, then hexadecimal 2F3.

BinaryHexBinaryHex
0000010008
0001110019
001021010A
001131011B
010041100C
010151101D
011061110E
011171111F

Reverse the mapping for hex to binary. Preserve four bits for every source hex digit while expanding; remove leading zeroes only after deciding whether a fixed field width matters. For a byte sequence, two hex digits are one byte, so removing a leading pair removes data rather than formatting.

Convert binary and octal in three-bit groups

Because 8 equals 23, group binary digits in threes from the right. The same 1011110011 becomes 001 011 110 011, which maps to octal 1363. Reverse the mapping by expanding every octal digit into exactly three bits.

Octal and hexadecimal can interconvert through binary without decimal arithmetic: expand octal triplets, regroup the complete bit string into four-bit nibbles, then map to hex. Keep lookup padding separate from significant field width.

Use powers or repeated division for other directions

Hexadecimal 2F3 becomes decimal by evaluating 2×16² + 15×16 + 3 = 755. Decimal 755 becomes hex by repeated division by 16: the remainders are 3, 15, and 2, read upward as 2F3. Use divisor 8 for octal.

Horner's method is a useful check: scan 2F3 left to right, multiply by 16, and add the next digit. Totals 2, 47, and 755 reach the same value. ECMAScript defines BigInt as an arbitrary-precision integer type; a browser tool should still bound input and output for responsiveness.

Keep sign, width, and value separate

A leading minus sign expresses a mathematical negative. A fixed-width two's-complement pattern is another representation that requires a width. At eight bits, 11111111 is unsigned 255 or signed −1; without a stated interpretation, the bits do not carry a unique signed meaning.

Leading zeroes do not change an unsigned value, but they preserve widths such as 8, 16, 32, or 64 bits. Leading ones can be sign extension for a negative two's-complement value. Read the explicit-width signed binary guide before trimming either.

Do not translate numeric digits as text bytes

Binary integer 10 represents decimal two. Text “10” contains Unicode characters U+0031 and U+0030, whose UTF-8 bytes are hexadecimal 31 30. Number-base conversion preserves a quantity; character encoding maps text to bytes. Use the Binary Translator for UTF-8 bytes and the ASCII Table for one code lookup.

Check every conversion independently

  1. Label the input base. A bare numeral does not identify its radix.
  2. Validate every digit. Binary rejects 2, octal rejects 8 and 9, and hex rejects letters beyond F.
  3. Use one complete method. Choose powers, Horner's method, repeated division, or direct power-of-two grouping.
  4. Convert back differently. A round trip catches reversed remainders and misplaced groups.
  5. Record sign and width. Do not call a high bit a sign bit until the representation defines it.
  6. Format last. Add prefixes, separators, padding, and case after the exact value is known.

Want to check a worked result? Convert a bounded whole-number value across binary, octal, decimal, and hexadecimal with explicit signed width and formatting.

Open the Binary Converter

Frequently asked questions

What is the easiest way to convert binary to decimal?

Multiply each binary digit by its power of two and add the nonzero terms. An equivalent left-to-right method repeatedly doubles the running total and adds the next bit.

How do I convert decimal to binary by hand?

Repeatedly divide the nonnegative integer by two, record each remainder, and read the remainders from last to first. Each remainder is zero or one because the divisor is two.

Why can binary convert directly to hexadecimal?

Sixteen is two to the fourth power, so every hexadecimal digit corresponds to exactly four binary bits. Group bits from the right and map each group without using decimal as an intermediate.

How does binary convert directly to octal?

Eight is two to the third power, so every octal digit corresponds to exactly three binary bits. Group from the right, pad only the leftmost group when needed, and map each triplet to a digit from zero through seven.

Do leading zeroes change a converted number?

Leading zeroes do not change an unsigned mathematical value, but they can preserve a required bit or byte width. Keep them when a protocol field, register, test vector, or serialized representation defines that width.

Can these methods convert binary fractions exactly?

The worked methods here cover whole numbers. Fractions use negative powers and can repeat forever in another base, so an implementation must define precision, rounding, and how it marks a repeating or truncated result.