... by which I mean the number of digits in a number.
Fails on some corner cases, e.g. getLength(1000) = 3 (incorrect), but getLength(1001) = 4.
I could convert to a Variant(String) and measure that, but is there a better way using numbers?
Just thought of
look good?
Code:
Function getLength(a)
Length = Int(Log(a) / Log(10)) + 1
getLength = Length
End Function
I could convert to a Variant(String) and measure that, but is there a better way using numbers?
Just thought of
Code:
do while a > 0
a = a / 10
Length = Length + 1
loop