how can i compute the length of an integer?
100 views (last 30 days)
More Answers (2)
Davide Ferraro on 4 Jan 2013
Casting the variable into a string may be risky because you may get to "unexpected" cases such as:
int = 12345678901234567890123
You may consider a numeric approach using LOG10: floor(log10(int))+1 all numbers between 10 and 100 will have a LOG10 between 1 and 2 so you can use FLOOR to get the lower value (1 in this case) and then you need to add the value 1 cause you are trying to compute the number of digits and not the power of ten.