Thread: counting digits
View Single Post
Old Apr 10th, 2007, 10:16 AM   #1
rwm
Professional Programmer
 
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 2 rwm is on a distinguished road
counting digits

Hey,

im writing some code for padding files.

Im wondering how i can count the number of digits in an integer...

i.e.

int a = 232;
int b = 9343;
int c = 23;
int d = 1;

a would have 3 digits, b would have 4 digits, c would have 2 and d would have 1 digit.

i've looked all over - all i can find is bitwise stuff - thats not what i want - the number of set bits is not always the same as the number of digits in the integer...

hope someone can help!

thanks!

rwm is offline   Reply With Quote