- #1
chaoseverlasting
- 1,050
- 3
I'm writing a program to convert between the different number systems (from decimal to any base), I know what the general algorithm is and how to implement it. The problem I am facing is, that I don't know how do decide the number of digits in the converted number.
For example, if I were to convert 10 from decimal to binary, I would get 1010, but the number of digits has changed from 2 to 4. How do you decide the number of digits in the new number (1010 in this case).
I know that roughly, if youre changing to a base greater than 10, the number of digits should decrease, and if converting to a base lesser than 10, the digits should increase, but don't know by how much.
For example, if I were to convert 10 from decimal to binary, I would get 1010, but the number of digits has changed from 2 to 4. How do you decide the number of digits in the new number (1010 in this case).
I know that roughly, if youre changing to a base greater than 10, the number of digits should decrease, and if converting to a base lesser than 10, the digits should increase, but don't know by how much.