To convert from base to decimal, multiply each digit by its position value ( raised to the position) and sum. To convert from decimal to base , repeatedly divide by and collect remainders.
Example: Convert (base-5) to decimal. . Now convert 38 to base-5: rem , rem , rem . Reading up: .
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.