Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #convers numbers
- strings = '0123456789ABCDEF'
- def to_val(s):
- return strings.find(str(s))
- def to_str(v):
- return strings[v]
- def convert(num, what, to):
- ans = ''
- al_num = str(num)[::-1]
- for x, last in enumerate(al_num):
- num = to_val(last) * what ** x
- print('Checking for ', num)
- b = 1
- while num > 0:
- perf = (num * b) % to
- if perf > 0:
- ans = to_str(perf) + ans
- num = num // to
- print(ans)
- if __name__ == '__main__':
- convert('FF', 16, 2)
Add Comment
Please, Sign In to add comment