molecalculator

Moles & Molar Mass

Number of Any Base Calculator: How It Works

Calculator No. 01-8484 · 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 calculator converts a number from any base (2 through 36) into its decimal (base-10) equivalent, and it can also convert a decimal number into any other base. You enter the number, select its base, and the calculator returns the value in base 10, plus the same number expressed in binary, octal, and hexadecimal for quick reference.

Formula

Every positional numeral system works the same way: each digit is multiplied by the base raised to the power of its position, counting from right to left starting at 0. For a number dn-1dn-2…d1d0 in base b, the decimal value is:

Decimal = dn-1 × bn-1 + dn-2 × bn-2 + … + d1 × b1 + d0 × b0

  • di – the digit at position i (0 to 9 for bases up to 10; A=10, B=11, … Z=35 for higher bases)
  • b – the base (radix), an integer from 2 to 36
  • n – the number of digits

Converting from decimal to another base uses repeated division: divide the decimal number by the target base, record the remainder as the least significant digit, and repeat with the quotient until it becomes zero. The remainders, read in reverse order, give the digits in the new base.

Worked Example

Using the default input: convert 101101 from base 2 to decimal.

  1. Write the digits with their positions: 1 (position 5), 0 (4), 1 (3), 1 (2), 0 (1), 1 (0).
  2. Multiply each digit by 2position:
  3. 1×25 = 32
  4. 0×24 = 0
  5. 1×23 = 8
  6. 1×22 = 4
  7. 0×21 = 0
  8. 1×20 = 1
  9. Sum: 32 + 0 + 8 + 4 + 0 + 1 = 45

So 1011012 = 4510. The calculator also shows 45 in octal (55) and hexadecimal (2D).

Assumptions

  • The input number is a valid representation in the given base (digits less than the base).
  • Bases are limited to 2–36, using digits 0–9 and letters A–Z.
  • Only integer (whole) numbers are considered; fractional bases are not handled.
  • No sign is assumed; negative numbers are not supported in this version.

Why Use Different Bases?

Base 10 is natural for humans because we have ten fingers, but computers operate in base 2 (binary) because electronic switches have two states. Base 8 (octal) and base 16 (hexadecimal) are shorthand for binary: each octal digit corresponds to three binary bits, and each hex digit to four bits. Programmers use hex to write memory addresses and color codes (e.g., #FF5733). Base 64 is used in encoding data for email and URLs, though it uses a different character set.

Understanding base conversion helps you read low-level code, understand how data is stored, and solve problems in digital logic and cryptography.

How to Choose the Right Base

When you need to convert, the base you choose depends on the context:

  • Binary (base 2) – for bitwise operations, machine code, and understanding CPU arithmetic.
  • Octal (base 8) – sometimes used in Unix file permissions (e.g., chmod 755) and older systems.
  • Decimal (base 10) – for everyday math and human-readable output.
  • Hexadecimal (base 16) – for memory addresses, color codes, and debugging.
  • Base 36 – for compact alphanumeric identifiers, as it uses all digits and letters.

For most conversion tasks, you’ll input a number in its original base and get the decimal value, then convert that to whatever base you need.

Common Mistakes and Misconceptions

A frequent error is treating a number like “10” as ten in every base. In base 2, “10” equals 2; in base 16, it equals 16. Always check the base. Another mistake is using digits that are not allowed in the base (e.g., using ‘9’ in base 5). Also, when converting from decimal to another base, forgetting to read the remainders in reverse order gives a completely wrong result.

A common misconception is that base conversion changes the value of a number. It does not – it only changes the representation. The quantity 45 (decimal) is the same as 101101 (binary).

Limits of the Calculator

This calculator handles non-negative integers only. It does not support fractional numbers (like 10.11 in binary) or negative numbers. For those, you would need a more advanced tool that handles place values for fractions (negative powers of the base) and sign bits. Also, the maximum base of 36 is conventional because it uses the 10 digits plus 26 letters; bases above 36 require additional symbols.

Frequently Asked Questions

How do I convert a number from base 10 to binary manually?

Divide the decimal number by 2 repeatedly, writing down the remainder each time. For example, to convert 45 to binary: 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 the remainders from bottom to top: 101101.

What does the letter ‘A’ mean in hexadecimal?

In bases greater than 10, letters represent digits above 9. ‘A’ = 10, ‘B’ = 11, up to ‘F’ = 15 in hex. In base 36, ‘Z’ = 35. The calculator accepts uppercase letters; lowercase is auto-converted.

Why is hexadecimal used in programming?

Because one hex digit exactly represents four binary bits, making it compact and easy to convert. For instance, the binary number 1111 0000 is simply F0 in hex. Programmers use hex to write memory addresses, color values, and bit masks without writing long strings of 1s and 0s.

Can this calculator convert between two non-decimal bases directly?

Yes, indirectly. The calculator first converts your input to decimal, then from decimal to the target base. This two-step method is standard because it’s simpler to implement. For example, to convert from base 8 to base 16, you’d first convert octal to decimal, then decimal to hex.

What is the largest number this calculator can handle?

The calculator uses standard JavaScript numbers, which can safely represent integers up to 253 – 1 (about 9 quadrillion). Inputs that produce larger decimal values may lose precision. For most practical purposes, this is more than enough.

Does the base have to be a whole number?

Yes, bases are integers from 2 to 36. Fractional bases (like base 2.5) are theoretically possible but extremely rare and not supported here. This calculator follows the standard convention of integer bases.

Related

Formula used
in num | Number to convert | - | 101101 | 0
in b | Base of input | - | 2 | 2
out dec | Decimal value | - | convert_to_decimal(num, b) | 0
out bin | In binary (base 2) | - | decimal_to_base(dec, 2) | 0
out oct | In octal (base 8) | - | decimal_to_base(dec, 8) | 0
out hex | In hexadecimal (base 16) | - | decimal_to_base(dec, 16) | 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 →