Search code examples
mathradixmixed-radix

Radix number representation


I have recently started learning Logic Designs and I have a few things that I don't quite understand.

Let's say you are given a certain value in seconds (say 3,000,000), and are asked to convert to weeks, days, hours, minutes and seconds (Mixed Radix). How would you convert it? I tried dividing the value with 60 first (for seconds), Used the quotient (?) as the first number, then divided the remainder again with 60 (this time for number of minutes) and so on for each radix (60s, 60m, 24h, 7d, 52w). Is this how you are supposed to solve it?

I also would like to know how to find the maximum value that can be represented by x vectors (eg. 4) with a radix (eg. 6). I thought it would be the sum of the value for each vector place (216, 36, 6, 1), thus being 259. But I don't think it's correct.

I've tried finding any help online but couldnt find any that gave an easy explanation.


Solution

  • For you first question (taking number of seconds N = 3,000,000):

    • seconds = N mod 60
    • minutes = (N - seconds) / 60
    • hours = minutes / 60
    • days = hours / 24
    • weeks = days / 7

    Where / is integer division (with truncation instead of rounding).

    For your second question, you must multiply the maximum value of each place by its size. The same applies to, say, any number system, e.g. 9999 in decimal: the maximum is not 9 + 9 + 9 + 9 = 36, but 9 * 1000 + 9 * 100 + 9 * 10 + 9 * 1.