The short answer: every base is a place-value system. In base b, each digit is multiplied by b raised to its position, counting from 0 on the right. Binary uses 0–1, octal 0–7, decimal 0–9, and hexadecimal 0–9 plus A–F for 10–15. So 10110110₂ = 182 = B6₁₆ = 266₈, and 255 = 11111111₂ = 377₈ = FF₁₆. Convert through decimal, or group bits directly: four binary digits make one hex digit and three make one octal digit.

Key takeaways

  • Position, not the number of symbols, sets the value. The string 10 means 2, 8, 10, or 16 depending on its base.
  • Hexadecimal is compact binary. One hex digit is exactly four bits, so one byte is two hex digits.
  • Octal is three bits per digit. It survives mainly in Unix file permissions and a few legacy formats.
  • Repeated division converts decimal to any base. Read the remainders from last to first, then check by expanding.
  • Integer conversion is exact. Fractions and values above 2⁵³−1 need a different method.

Place value is the whole system

Write the decimal number 4,207 and you are implicitly summing 4 × 10³ + 2 × 10² + 0 × 10¹ + 7 × 10⁰. The same structure works in every base; only the multiplier changes. In base b, the digit in position n from the right has weight bⁿ. Position 0 is the units column, position 1 is the base column, position 2 is the base squared, and so on.

That single rule explains why 1010₂ is ten rather than one thousand and ten. The leftmost 1 sits in the 2³ = 8 column, the next 1 in the 2¹ = 2 column, and the zeros mark the 4 and 1 columns. Add the weights of the set bits and the value appears. No separate conversion rule is needed: binary, octal, decimal, and hex are the same algorithm with different bases. A digit must always be smaller than the base, which is why 9 + 1 carries into a new column in decimal.

The four bases and their digit alphabets

Binary (base 2) uses two symbols and matches the two states of a bit. Octal (base 8) was common on minicomputers because three bits fit one digit. Decimal (base 10) is the everyday system. Hexadecimal (base 16) uses 0–9 plus A–F for ten through fifteen, in either case.

Programming languages mark the base with a prefix: 0b for binary, 0o for octal, and 0x for hexadecimal. Those prefixes are notation, not part of the number, and a plain input field will usually reject them. A leading zero is also ambiguous across languages: it means octal in some C-style contexts and nothing special in others, so state the base explicitly.

Binary to decimal by weights

List the powers of two from the right: 1, 2, 4, 8, 16, 32, 64, 128. For 10110110₂, the set bits are at positions 7, 5, 4, 2, and 1, so the value is 128 + 32 + 16 + 4 + 2 = 182. The all-ones byte 11111111₂ is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255, the largest value one byte can hold.

The pattern generalises. An unsigned n-bit number covers 0 to 2ⁿ−1, so eight bits cover 0–255, ten bits cover 0–1023, and sixteen bits cover 0–65,535. Doubling the bit width squares the number of patterns. This is why 8-bit colour channels run from 0 to 255 and why a 16-bit counter wraps at 65,536 rather than at 65,000.

Decimal to another base by repeated division

Divide by the target base, record the remainder, and repeat on the quotient until the quotient reaches zero. Then read the remainders from last to first. For 1000 in hex: 1000 ÷ 16 = 62 remainder 8; 62 ÷ 16 = 3 remainder 14, written E; 3 ÷ 16 = 0 remainder 3. Reading upward gives 3E8₁₆.

The same number in octal: 1000 ÷ 8 = 125 remainder 0; 125 ÷ 8 = 15 remainder 5; 15 ÷ 8 = 1 remainder 7; 1 ÷ 8 = 0 remainder 1. The digits are 1750₈. In binary the result is 1111101000₂. Each answer can be checked by expanding it: 3 × 256 + 14 × 16 + 8 = 1000, and 1 × 512 + 7 × 64 + 5 × 8 = 1000.

The most common slip is reading the remainders in the order they were produced, which reverses the digits; a second check in another base catches it. Long division is slow but never loses precision, which is why it remains the reliable hand method.

Hex and binary map four bits at a time

Because 16 = 2⁴, each hex digit corresponds to exactly four binary bits. Expand B6₁₆ by writing B = 1011 and 6 = 0110, then concatenate: 10110110₂. Going the other way, split from the right into groups of four and pad the leftmost group with leading zeros. The binary 101101 becomes 0010 1101, which is 2D₁₆.

This fixed mapping is why hex is used for memory addresses, machine code, RGB colours such as #FF8800, MAC addresses, and byte dumps. Two hex digits describe one byte without commas or long runs of bits. Dropping a leading zero inside a byte-oriented field turns 0x0A into 0xA, which may still be the same number but can break a fixed-width format.

Octal maps three bits at a time

Octal works the same way with groups of three bits, because 8 = 2³. The permission string 755₈ expands to 111 101 101₂ and equals 493₁₀. Group from the right and pad the leftmost group: 1010₂ becomes 001 010, which is 12₈, not 101 0, which would read as 50₈.

Octal survives mainly in Unix file modes, where each digit encodes read, write, and execute bits for one class of user. It also appears in a few legacy protocols and older character codes. Elsewhere hexadecimal has largely replaced it, because a byte divides evenly into two hex digits but not into a whole number of octal digits.

Where bases show up in practice

Hexadecimal is the working notation for memory addresses, colour values, cryptographic hashes, and network hardware identifiers. Binary appears in bitmasks, hardware registers, and flag fields, where each bit has a defined meaning. Octal remains in chmod permissions. Decimal is the human default, while base 2 is what the hardware actually stores.

When a specification mixes bases, convert everything to one base before comparing. The hex value 0x10 is 16, not 10; 0b10 is 2. Labelling the base on every value prevents that class of error.

Common mistakes

Reading 10 as ten in every base. 10₂ = 2, 10₈ = 8, 10₁₀ = 10, and 10₁₆ = 16. The symbols are identical; the value is not.

Using digits the base does not have. A 2 in binary or a G in hex makes the string invalid, not larger. Validation should reject it rather than silently truncate.

Grouping from the left. Binary-to-hex and binary-to-octal groups start at the right. Starting at the left shifts every group and produces a plausible but wrong answer.

Dropping leading zeros. 0010 1101 and 101101 are the same value, but a fixed-width field may interpret a missing leading zero as a different byte.

Adding a prefix. 0x, 0b, and 0o are language notation; a field that expects plain digits may reject them or read the x as a hex digit.

Assuming signed behaviour. This converter handles non-negative integers. Two’s complement, sign bits, and fixed-width overflow are separate conventions that depend on the system.

Precision and limits

Integer conversion itself is exact: 182 is B6 in every implementation. The practical limit is the arithmetic used to parse the digits. JavaScript numbers represent integers exactly only up to 2⁵³−1 = 9,007,199,254,740,991. Above that, parsing can round and the displayed binary or hex may be wrong in the last digits; use a big-integer library.

Fractions are a different problem. 0.1₁₀ has no finite binary expansion, so a binary fraction repeats and must be rounded, just as one third repeats in decimal. This converter accepts whole numbers only, which avoids that issue. Leading zeros do not change a value, hex letters are case-insensitive, and a result should always be shown with its base, because the digits alone do not identify the number.

Frequently asked questions

Why is 10 not always ten?

Because the value of a digit depends on its position and the base. In base 2, 10 means one 2 and zero 1s, so it equals 2. In base 8 it equals 8, in base 10 it equals 10, and in base 16 it equals 16.

How do I convert binary to hex by hand?

Group the bits into fours from the right, pad the leftmost group with zeros, and replace each group with its hex digit. 10110110 becomes 1011 0110, which is B6.

What does 0x mean?

It is a prefix used in many programming languages to mark a hexadecimal literal. 0xFF is 255. The prefix is not part of the number and is usually not accepted by a plain converter input.

Can I convert fractions or negative numbers?

Not with this converter. It accepts non-negative integers in bases 2, 8, 10, and 16. Fractions need a radix point and a rounding rule; negative values need a sign convention such as two’s complement.

What is the largest integer this method handles exactly?

In JavaScript arithmetic, 2⁵³−1 = 9,007,199,254,740,991, written in hex as 1FFFFFFFFFFFFF. Beyond that, the last digits may be rounded, so use arbitrary-precision integers for exact work.

Why does hexadecimal use letters?

Base 16 needs sixteen distinct symbols. The digits 0–9 supply ten, and A–F supply the values ten through fifteen. Without letters, a single hex digit could not be written unambiguously.

Further reading

Keep exploring

Read next Hex to RGB: Color Codes, Channels, and Alpha A hex code is three base-16 channel values in one string. Learn how RR, GG, and BB become… Read next Density Conversion: kg/m³, g/cm³, and lb/ft³ Density is mass per volume, and the metric and imperial units are linked by exact factors. Learn the… Read next Frequency Conversion: Hertz, RPM, and Period Convert hertz, kilohertz, megahertz, and gigahertz, then relate frequency to period, rpm, and angular frequency with exact factors…