Answer the question
In order to leave comments, you need to log in
What are the ways to translate number systems?
Is there any universal way to translate numbers from one number system to another? Or for the speed of translation, some kind of easy way. Thank you.
Answer the question
In order to leave comments, you need to log in
There are standard and bicycle ways.
For example, the standard python function int, which takes a string argument, can take a base as an optional second:
The bicycle method is also simple:
def to_str(n, radix):
l = []
while n:
n, d = divmod(n, radix)
l.append("0123456789ABC...Z"[d])
return ''.join(reversed(l))
print(to_str(12345, 10))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question