Alex Rivera | Logout

Converting a decimal to a mixed-radix (base) number

Asked 2009-04-17T06:55:56.327
9

How do you convert a decimal number to mixed radix notation?

I guess that given an input of an array of each of the bases, and the decimal number, it should output an array of the values of each column.

Edit
Report

1 Answer

7

Pseudocode:

bases = [24, 60, 60]
input = 86462                       #One day, 1 minute, 2 seconds
output = []

for base in reverse(bases)
    output.prepend(input mod base)
    input = input div base          #div is integer division (round down)
answered 2009-04-17T07:05:51.233

Your Answer