Math Fundamentals18 sections · 814 units
Open in Course

Converting Between Any Bases

Universal method

To convert from base bb to decimal, multiply each digit by its position value (bb raised to the position) and sum. To convert from decimal to base bb, repeatedly divide by bb and collect remainders.

Example: Convert 1235123_5 (base-5) to decimal. 1235=1×52+2×51+3×50=25+10+3=3810123_5 = 1 \times 5^2 + 2 \times 5^1 + 3 \times 5^0 = 25 + 10 + 3 = 38_{10}. Now convert 38 to base-5: 38÷5=738 \div 5 = 7 rem 33, 7÷5=17 \div 5 = 1 rem 22, 1÷5=01 \div 5 = 0 rem 11. Reading up: 1235123_5.

The algorithm works for any base. The pattern is always the same: expand to decimal using powers, or divide repeatedly to get digits. Most programming languages have built-in functions for common bases.