Number Base

Compare Calculations

Downloads

Includes your inputs and results for this calculation, plus any additional calculations you've compared.

Rewriting the Same Value Across Binary, Octal, Decimal, and Hex

A number base (or “radix”) is how many distinct digits a numeral system uses before it carries over to the next place value — decimal uses 10 (0–9), binary uses 2 (0–1), octal uses 8 (0–7), and hexadecimal uses 16 (0–9 then A–F). Enter a whole number in any of these four bases, and this calculator shows the same value written in all four at once.

Binary is how computers represent every value internally (each digit is one “bit”); hexadecimal is a common shorthand for binary in programming (each hex digit stands in for exactly 4 binary digits, so it’s far more compact to read and type); octal shows up in older Unix file permissions and some low-level contexts. Decimal is just the everyday base-10 system.

The Formula

Every positional numeral system works the same way: each digit is multiplied by the base raised to its place-value power, then summed:

Value=i=0ndi×Basei\vA{\text{Value}} = \sum_{i=0}^{n} d_i \times \vB{\text{Base}}^i

where did_i is the digit at position ii (counting from 0 at the rightmost digit). Converting to a different base repeatedly divides the decimal value by the new base, recording each remainder — the reverse of the sum above.

Worked Example

Converting binary 11111111 to its other three bases:

  1. Read right to left, each 1 contributes its place value: 27+26+25+24+23+22+21+20=2552^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0 = 255.
  2. Decimal: 255.
  3. Octal: dividing 255 by 8 repeatedly (255 ÷ 8 = 31 r7, 31 ÷ 8 = 3 r7, 3 ÷ 8 = 0 r3) reads the remainders bottom-to-top as 377.
  4. Hexadecimal: 255 ÷ 16 = 15 r15, 15 ÷ 16 = 0 r15 — both remainders are 15 (F in hex), giving FF.

Key Factors to Consider

  • A single byte (8 bits) can represent exactly 256 distinct values — 0 through 255 in decimal, or 00 through FF in hexadecimal. This is exactly why 255/FF is such a common reference value in computing — it’s the maximum value a single byte can hold, which shows up everywhere from RGB color channels (0-255 per channel) to networking and file formats.
  • Octal was historically more common than it is today, largely due to older computer word sizes. Octal (base 8) maps cleanly onto groups of 3 binary digits, which suited computers built around word sizes divisible by 3 bits — modern computing has largely shifted to hexadecimal (which maps onto groups of 4 bits) since most modern hardware uses word sizes divisible by 4 and 8, though octal still appears in specific contexts like Unix file permission notation (e.g. chmod 755).
  • A common programmer’s error is confusing a number’s base from context alone. The digits “10” mean very different values depending on base — 10 in decimal, 2 in binary, 8 in octal, 16 in hexadecimal — which is why programming languages typically require an explicit prefix (like 0x for hex or 0b for binary) to remove any ambiguity about which base is intended.
  • Any whole number can theoretically be represented in ANY base, not just these four. Binary, octal, decimal, and hexadecimal are simply the four bases with the most common real-world use in computing and everyday math — the same positional-notation principle this calculator uses extends to any base, like base 3, base 20, or base 60 (the basis of how time and angles are traditionally divided).

Common Mistakes

  • Reading a mixed-base number without a prefix as decimal by default. “10” means ten in decimal but only two in binary — always check (or state) which base a number is written in before doing arithmetic with it.
  • Assuming leading zeros change the value. Just like in decimal, 0011 in binary is the same value as 11 — leading zeros are only meaningful for fixed-width formatting (like showing a full byte), not for the number’s actual value.
  • Forgetting that hex digits above 9 use letters, not two-digit numbers. Hexadecimal 10 is written as A, not 10 — writing 10 in hex actually means sixteen in decimal, a common source of off-by-a-lot errors.
  • Trying to convert a negative number directly. As the FAQ above notes, negative binary/hex values depend on a chosen bit-width and two’s-complement convention — there’s no single unambiguous conversion the way there is for non-negative whole numbers.

Useful to Know

  • Working with network addresses instead of arbitrary numbers? IP Subnet Calculator applies this same binary/decimal relationship specifically to IPv4 addresses.
  • Need very large or very small decimal numbers in a compact form? Scientific Notation Calculator handles that kind of conversion instead.
  • Curious about a much older positional-adjacent numbering system? Roman Numeral Calculator converts to and from Roman numerals, which use a completely different (non-positional) approach.

Source: Standard positional numeral system conversion.

Frequently Asked Questions

What is a number base (radix)?

A number base is how many distinct digits a numeral system uses before carrying over to the next place value. Decimal (base 10) uses digits 0-9; binary (base 2) uses only 0 and 1; octal (base 8) uses 0-7; hexadecimal (base 16) uses 0-9 then the letters A-F to represent 10-15.

Why do computers use binary?

Computer hardware is built from switches that are only ever fully on or fully off, which maps naturally onto binary's two digits (1 and 0). Every value a computer stores or processes is ultimately represented in binary, even though programmers usually work with more human-readable bases like decimal or hexadecimal.

Why is hexadecimal used instead of binary in programming?

Each hexadecimal digit represents exactly 4 binary digits (bits), so a hex number is about a quarter of the length of the equivalent binary number while representing the exact same value — much easier for a person to read, type, and compare than a long string of 1s and 0s.

Can this calculator handle negative numbers?

No — representing a negative number in binary or hexadecimal requires choosing a fixed bit-width and a two's-complement convention, which varies by context (8-bit, 16-bit, 32-bit, etc.). This calculator is scoped to non-negative whole numbers, where the conversion is unambiguous.

Confirm Your Age

To create an account, please tell us your birth month and year.