0

I've been working on this mini app which adds numbers of whatever bases the user wants and then converts them to the base that he/she wants. Is it okay if I implement it this way? Or is there a better way?

  • 1
    Did you try it to see if it worked? If you've already got code that does base conversions, this should be a pretty simple thing to answer yourself in just a couple of minutes. – Ken White May 20 '20 at 00:40
  • I think it's fine, there is pretty much no other way. If the base is explicitly specified, it takes few time to convert to base 10, then to desired base – Alex Chashin May 20 '20 at 01:15

1 Answers1

0

If the bases of both the numbers you're trying to add are the same, then you can simply add then by writing a small piece of code. And then you'd only have to convert the sum into to the desired base (if you need to).

Otherwise, it is always a safe option to convert your numbers into decimal and then add them simply using operators and then converting the sum into the desired base (although then you'd probably have to do 3 conversions max).