I am trying to make a program that calculate the width or how many numbers a float contains. I need this to make good looking outputs in console. For example, the width of the following numbers are:
4 (1)
23 (2)
0.3 (3 because the . has the width of one)
0.45 (4)
12.34 (5)
0 (1)
I have tried to check if the number == 0
then the width is 1
and done, and else multiply the number with 10
until there is no decimals float == (int)float
and then calculating how many times it is needed to divide by 10
to get a number float < 0.
I have tried everything I have found at the internet without any real luck...