Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

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

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...