molecalculator

Moles & Molar Mass

Convert Base 10 to Base n: Steps & Examples

Calculator No. 01-8455 · 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.

To convert a base 10 (decimal) number to another base n, repeatedly divide the decimal number by n, record the remainders, and read them from last to first. For example, 25 in base 10 equals 11001 in base 2, because 25 ÷ 2 gives remainders 1,0,0,1,1 read upward. This article explains the method, shows worked examples for bases 2, 8, and 16, and covers fractional conversions, common mistakes, and why the algorithm works.

Note: The calculator above uses a built-in function; for the article, we explain the manual steps. The default 255 in base 16 is FF.

Formula

The conversion algorithm is based on the division-remainder method. For a decimal integer D and target base n (with 2 ≤ n ≤ 36), the result is a sequence of digits dkdk-1…d0 such that:

D = dk·nk + dk-1·nk-1 + … + d1·n + d0

Each digit di is an integer from 0 to n-1. The steps:

  • Divide D by n. The remainder becomes the least significant digit (rightmost).
  • Replace D with the integer quotient.
  • Repeat until the quotient is 0.
  • Write the remainders in reverse order (last remainder first).

For bases above 10, digits 10-35 are represented by letters A-Z (10=A, 11=B, …, 35=Z).

Worked Example

Convert 255 (base 10) to base 16 (hexadecimal).

  1. 255 ÷ 16 = 15 remainder 15 → digit F (15 = F)
  2. 15 ÷ 16 = 0 remainder 15 → digit F
  3. Reverse: FF

So 25510 = FF16.

Check: 15×16 + 15 = 240 + 15 = 255.

Another example: Convert 42 to base 2.

  1. 42 ÷ 2 = 21 remainder 0
  2. 21 ÷ 2 = 10 remainder 1
  3. 10 ÷ 2 = 5 remainder 0
  4. 5 ÷ 2 = 2 remainder 1
  5. 2 ÷ 2 = 1 remainder 0
  6. 1 ÷ 2 = 0 remainder 1
  7. Reverse: 101010

So 4210 = 1010102.

Assumptions

  • The input is a non-negative integer. For negative numbers, convert the absolute value and add a minus sign.
  • The target base is an integer between 2 and 36 (common bases: 2, 8, 10, 16).
  • Digits above 9 use uppercase letters A-Z.
  • For fractional parts, a separate method is used (see below).

Why the Algorithm Works

The division-remainder method exploits the fact that any number can be expressed as a sum of powers of the base. When you divide by n, the remainder is exactly the coefficient of n0 (the units digit). The quotient then represents the remaining higher-place values. Repeating the division peels off each digit from right to left. This is a direct consequence of the Euclidean division theorem: for any integer D and base n, there exist unique integers q and r such that D = q·n + r, with 0 ≤ r < n.

Converting Fractional Parts

To convert a decimal fraction (e.g., 0.625) to base n, use multiplication:

  • Multiply the fraction by n. The integer part becomes the next digit (to the right of the point).
  • Take the fractional part of the result and repeat.
  • Stop when the fraction becomes 0 or you have enough digits.

Example: Convert 0.625 to base 2.

  1. 0.625 × 2 = 1.25 → digit 1, fraction 0.25
  2. 0.25 × 2 = 0.5 → digit 0, fraction 0.5
  3. 0.5 × 2 = 1.0 → digit 1, fraction 0.0

Result: 0.1012. Note that some fractions never terminate (e.g., 0.1 in base 2 is 0.000110011… repeating).

Common Mistakes and Pitfalls

  • Forgetting to reverse the remainders: the first remainder is the least significant digit, not the most significant.
  • Using the wrong base for digits: for base 16, digits 10-15 must be A-F, not 10-15 as two-digit numbers.
  • Confusing the quotient and remainder: the remainder is always less than the base.
  • Mixing integer and fractional conversion methods: use division for the integer part, multiplication for the fractional part.
  • Rounding errors when converting fractions: always specify how many digits you need.

Choosing the Right Base

Different bases serve different purposes:

  • Base 2 (binary): Used in digital electronics and computer science because it maps directly to on/off states.
  • Base 8 (octal): Historically used in computing as a compact representation of binary (each octal digit = 3 binary bits).
  • Base 16 (hexadecimal): Standard in programming and memory addressing because each hex digit = 4 binary bits, making it easy to read.
  • Base 60 (sexagesimal): Used for time and angles (minutes, seconds).

For most everyday math, base 10 is natural because of human fingers. But when working with computers, base 16 is often more convenient than base 10 because it aligns with byte boundaries.

Frequently Asked Questions

How do I convert from base n back to base 10?

Multiply each digit by the base raised to its position (starting from 0 for the rightmost digit) and sum. For example, 1012 = 1×22 + 0×21 + 1×20 = 4 + 0 + 1 = 5.

What if the base is larger than 10?

Use letters for digits 10 and above. The convention is A=10, B=11, C=12, and so on up to Z=35. For example, in base 16, the decimal number 10 is written as A, 15 as F, and 255 as FF.

Can I convert negative numbers?

Yes, convert the absolute value as usual, then prefix a minus sign. For example, -42 in base 2 is -101010. Some computer systems use two’s complement representation, but that is a different convention.

Why does the calculator show a different result for fractional numbers?

Our calculator handles integers only. For fractional numbers, use the multiplication method described above. Many fractions do not terminate in base 2 or 16, so you must decide how many digits to keep.

Is there a shortcut for converting between binary and hexadecimal?

Yes, group binary digits in sets of four (from the right for integers, from the left for fractions) and replace each group with its hex equivalent. For example, 1010 11112 = AF16.

What is the largest base I can use?

In theory, any base greater than 1 is possible. In practice, we usually limit to base 36 (digits 0-9 and A-Z) because that covers all alphanumeric characters. Some systems extend to base 62 (adding lowercase letters), but that is less common.

Related

Formula used
in num | Decimal number (base 10) | - | 255 | 0
in base | Target base n | - | 16 | 2
out result | Result in base n | - | base_convert(num, base) | 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 →