-
Float Size
Maybe I am tired or something. But I cant figure out how to do this easily. If I have a float how can I tell its whole number size or places.
Example:
9 = 1 place
93 = 2 places
934 = 3 places
9349 = 4 places
93490 = 5 places
and so on.
I figure I could convert it to a string then get the length, but that seems like to much work. Anyone got a better idea?
-
Well I got this, unless someone has something better;
Code:
float f = 1235.00;
float t = f;
int i = 0;
while(t >= 1)
{
t = t / 10;
i++;
}
-
Don't know if taking the log to base 10 is better.