0

I am looking to implement a general base conversion algorithm. I was wondering if there already exists such a thing, since I couldn't find one.

Currently, I am able to go from int to int, but I also want support for negative, rational and, in principle, all complex numbers as both bases and the value to convert.

Does this already exists and if not, how would one do make this without considering each case individually (int->int, int->float, int->complex etc).

Tim
  • 1
  • Fair warning, this might be too broad. (Any community votes?) A possible alternative might be to pick one aspect that you don't know how to handle (e.g., convert to negative base, or convert to rational base). There is a ton written on base conversion, and it would help to show the research you've done and give an overview of the standard algorithms and what types of bases they do or don't support. – D.W. Mar 28 '24 at 20:29
  • See, e.g., https://cs.stackexchange.com/q/10318/755, https://math.stackexchange.com/q/79092/14578, https://en.wikipedia.org/wiki/Negative_base#Calculation, https://en.wikipedia.org/wiki/Non-integer_base_of_numeration#Conversion, https://www.irif.fr/~cf/publications/AFSwords05.pdf – D.W. Mar 28 '24 at 20:35
  • (One base to ponder is $\sqrt{-2}$.) – greybeard Mar 29 '24 at 09:00

0 Answers0