Search code examples
equationradix

1001_s = 19684_10 solving for S in and stating the base


This is a homework question and I don't want the solution, I just want a reference to how to solve similar questions like this. I believe it's explained my course textbook, "Computer Organization & Architecture: Themes and Variations", but I currently cannot afford the textbook.

Here's the question:

For each of the following numbers, state the base in use; that is, what are the values of r, s, and t?

  1. 25_r = 23_10

  2. 1001_s = 19684_10

  3. 1011_t = 4931_10

I recognize it's similar to solving an equation. I'm guessing I have to find r, s and t and they will be a specific base that matches the base ten number. I tried searching online for similar questions but I'm not sure what to search for so I have no clue where to start for solving these equations.


Solution

  • The procedure to convert from base b to base 10 is to multiply each digit in position k (from right to left, starting at 0) by b^k.

    I won't give away all of the answers but for 25 in base s, it is 2 * s^1 + 5 * s^0 = 23 which reduces to 2 * s + 1 = 23 or 2 * s = 18. Then s = 9.

    Since this is a programming website, I'll throw in a pseudocoded procedure to do check your answers with:

    procedure base_b_to_ten(int[] n, int base) {
        int sum = 0;
    
        for(int k=0; k<n.length; k++) {
            sum = sum + pow(n[n.length - k], base);
        }
    
        return base;
    }