molecalculator

Moles & Molar Mass

Base n to Decimal: Conversion Steps & Examples

Calculator No. 01-8448 · Updated · Formula and assumptions shown below

The calculator on this page is switched off while it is checked. The formula is below, and the worked example shows how to do the sum by hand.

For study and lab planning. The result follows from the numbers you enter and the formula shown. Check it against your method before you weigh, mix or dilute anything, follow the safety data sheet and your supervisor, and do not use it for clinical, dosing or medication work.

This page explains how to convert a number written in any base n to its decimal (base-10) equivalent. You enter the digits of the number and the base, and the calculator returns the decimal value using the standard positional notation method. The result is the sum of each digit multiplied by the base raised to the power of its position, counting from right to left starting at zero.

Formula

The general formula for converting a number with digits dk, dk−1, …, d1, d0 from base n to decimal is:

Decimal = dk × nk + dk−1 × nk−1 + … + d1 × n1 + d0 × n0

Where:

  • di is the digit in position i (each digit must be an integer from 0 to n−1)
  • n is the base (a positive integer greater than 1)
  • k is the position of the leftmost digit (equal to the number of digits minus 1)

For bases larger than 10, letters are used: A = 10, B = 11, C = 12, up to Z = 35. In this calculator, enter letters as their numeric values (e.g., for hexadecimal, enter 10 for A, 11 for B, etc.).

Worked Example

Convert the binary number 1011 (base 2) to decimal using the default values from the calculator.

Step 1: Write the digits with their positions from right to left, starting at 0:

  • Position 3: digit 1
  • Position 2: digit 0
  • Position 1: digit 1
  • Position 0: digit 1

Step 2: Apply the formula:

Decimal = 1 × 23 + 0 × 22 + 1 × 21 + 1 × 20

Step 3: Calculate each term:

  • 1 × 8 = 8
  • 0 × 4 = 0
  • 1 × 2 = 2
  • 1 × 1 = 1

Step 4: Sum the terms: 8 + 0 + 2 + 1 = 11

So 10112 = 1110. The calculator gives the same result: 11.

Assumptions

  • Digits are entered as space-separated integers, with the most significant digit first (left to right).
  • The base is a positive integer greater than 1.
  • Every digit is valid for the given base (0 to n−1); the calculator does not check this automatically, so the user must ensure validity.
  • Only whole numbers (no fractional parts or decimal points) are handled here.

How Positional Notation Works

Every number system we commonly use is positional: the value of a digit depends on where it sits. In decimal, the digit 5 in “50” means five tens, while in “500” it means five hundreds. The same principle applies in any base. The rightmost position is always the base0 place (units), the next position to the left is base1, then base2, and so on.

For base n, each position is worth n times more than the position to its right. In binary (base 2), the positions are 1, 2, 4, 8, 16, 32… In octal (base 8), they are 1, 8, 64, 512… In hexadecimal (base 16), they are 1, 16, 256, 4096…

To convert, you multiply each digit by its positional value and add everything together. This is the same arithmetic you already do with decimal numbers—you just replace the powers of 10 with powers of n.

Common Bases and Their Uses

While base 10 is standard for everyday arithmetic, several other bases appear regularly in computing and mathematics:

  • Base 2 (binary): The native language of digital circuits. Every value in a computer is ultimately stored as a sequence of bits (0 or 1). Binary is verbose but fundamental.
  • Base 8 (octal): Historically used in Unix file permissions (e.g., chmod 755) and some older computer systems. Each octal digit maps to exactly three binary digits.
  • Base 16 (hexadecimal): Widely used in programming, memory addresses, color codes (e.g., #FF5733), and debugging. Each hex digit maps to four binary digits, making it compact for representing bytes.
  • Base 60 (sexagesimal): Used for time (minutes and seconds) and angles (degrees, minutes, seconds). It survives from ancient Babylonian mathematics.

Understanding how to convert between these bases is essential for low-level programming, network addressing (IPv6 is written in hex), and digital electronics.

How to Choose the Right Method

For most conversions, the direct positional method shown above is the simplest. However, there are shortcuts when converting between bases that are powers of 2:

  • Binary to octal: Group binary digits in threes from the right, then convert each group to its octal digit (000→0, 001→1, 010→2, …, 111→7).
  • Binary to hexadecimal: Group binary digits in fours from the right, then convert each group (0000→0, 0001→1, …, 1111→F).
  • Octal to binary: Replace each octal digit with its three-bit binary equivalent.
  • Hexadecimal to binary: Replace each hex digit with its four-bit binary equivalent.

These shortcuts work because 8 = 23 and 16 = 24. For bases that are not powers of each other (e.g., binary to decimal, or decimal to hexadecimal), you must use the full positional arithmetic or repeated division.

Common Mistakes and How to Avoid Them

Several errors are easy to make when converting bases:

  • Starting the exponent at 1 instead of 0: The rightmost digit is always multiplied by base0 = 1, not base1. This mistake shifts every value by a factor of the base.
  • Reading digits in the wrong order: The most significant digit (leftmost) gets the highest power. Reading the number backwards gives a completely different result.
  • Using digits that are invalid for the base: In binary, only 0 and 1 are allowed. A digit like 2 in binary is meaningless. In octal, digits 8 and 9 are invalid. Always verify each digit is less than the base.
  • Forgetting letters in bases above 10: In hexadecimal, the digit “A” represents 10, not the letter’s alphabetical position. Convert letters to numbers before multiplying.
  • Mixing up the base value: Confusing octal (8) with hexadecimal (16) or decimal (10) will produce wildly incorrect results. Double-check the subscript or context.

A quick sanity check: for any base n, the number “10” always equals n in decimal. So 102 = 2, 108 = 8, and 1016 = 16. Similarly, the largest single digit in base n (which is n−1) is always one less than the base.

Limits of This Conversion Method

The positional method works for any whole number in any base, but it has practical limits:

  • Fractional parts: Numbers with a radix point (like 101.101 in binary) require negative exponents (base−1, base−2, etc.). This calculator does not handle fractions.
  • Very large numbers: Converting a 32-bit binary number requires computing powers up to 231, which is about 2.1 billion. This is fine for most purposes, but extremely long numbers (hundreds of digits) may exceed practical manual calculation.
  • Bases above 36: Standard notation uses digits 0–9 and letters A–Z, which covers bases up to 36. For higher bases, you would need custom symbols.
  • Negative numbers: The sign is handled separately; this method converts the magnitude only. In computing, negative numbers are often stored using two’s complement, which requires a different interpretation.

For fractional or very large conversions, consider using a programming language or a dedicated calculator with arbitrary precision.

Frequently Asked Questions

How do I convert a decimal number to base n?
Use repeated division. Divide the decimal number by n, record the remainder, and repeat with the quotient until it reaches zero. The remainders, read in reverse order (last to first), form the number in base n. For example, converting 11 to binary: 11 ÷ 2 = 5 remainder 1, 5 ÷ 2 = 2 remainder 1, 2 ÷ 2 = 1 remainder 0, 1 ÷ 2 = 0 remainder 1. Reading remainders backward gives 1011.

What does the subscript after a number mean?
The subscript indicates the base. For example, 10112 means the number 1011 is in base 2 (binary), not “one thousand eleven.” Without the subscript, the number is usually assumed to be decimal. Always look for or write the subscript to avoid ambiguity.

Why does 10 in binary equal 2 in decimal?
In any base n, the digits “10” represent one group of n plus zero units. In binary, n = 2, so 102 = 1 × 2 + 0 = 2. This is exactly how 10 in decimal means one group of ten.

Can I convert directly between two non-decimal bases without going through decimal?
Yes, but it is usually easier to go through decimal unless the bases share a common power (like 2 and 8, or 2 and 16). For direct conversion between arbitrary bases, you would expand each digit using the source base’s positional values, then regroup into the target base—this is essentially doing two conversions at once.

What is the largest digit allowed in base n?
The largest valid digit is n − 1. For base 10, the largest digit is 9. For base 2, it is 1. For base 16, it is 15 (written as F). Any digit equal to or greater than the base is invalid and indicates a mistake in the number’s representation.

How do I handle letters like A, B, C in hexadecimal?
Convert each letter to its numeric value: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. Then apply the same positional formula. For example, 2F16 = 2 × 16 + 15 = 32 + 15 = 47 in decimal.

Related

Formula used
in digits | Digits of the number (space-separated) | - | 1 0 1 1 | 0
in n | Base | - | 2 | 2
out dec | Decimal value | - | sum(digits[i] * n^(len(digits)-1-i)) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation with the constants and conversion factors written on the page, rounded as each result states. See method and constants, the disclaimer or report an error.

More in this section

The whole Moles & Molar Mass section →