Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...