How can i figure out the number of numbers in an int value
IE
12345 has 5 numbers in it.
Need this beacause i'm making a simple method to convort a int to a string;
How can i figure out the number of numbers in an int value
IE
12345 has 5 numbers in it.
Need this beacause i'm making a simple method to convort a int to a string;
Repeat division (with truncation) by 10 until you get 0.
12345 / 10 = 1234
1234 / 10 = 123
123 / 10 = 12
12 / 10 = 1
1 / 10 = 0
5 divisions => 5 digits
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
Thanks. i shall put it to good use. loop it till it equals 0
You can also take the base 10 log and round to the next highest integer (actually, take the log, cast to an int, and add 1). That would probably be faster.
will try that. got some code almost work using this method so i might just stick to this.. although speed is always better