radix

How to count the number of digits in numbers in different bases?

How to count the number of digits in numbers in different bases? Question: I’m working with numbers in different bases (base-10, base-8, base-16, etc). I’m trying to count the number of characters in each number. Example Number: ABCDEF Number of digits: 6 I know about the method based on logarithms but I’m facing some problems. …

Total answers: 4

How to convert an integer to a string in any base?

How to convert an integer to a string in any base? Question: Python allows easy creation of an integer from a string of a given base via int(str, base). I want to perform the inverse: creation of a string from an integer, i.e. I want some function int2base(num, base), such that: int(int2base(x, b), b) == …

Total answers: 35