How about this one?
Without hacking the generated Java code at compile time (yes, it is possible), this is the cleanest I can get:
You could write a clean Java function and call it from a library:
B4X:
Sub NumberOfDigits(n As Long) As Short
Dim i = 1 As Short, p = 10 As Long
Do Until n Mod p = n : p = p * 10 : i = i + 1 : Loop
Return i
End Sub
Without hacking the generated Java code at compile time (yes, it is possible), this is the cleanest I can get:
B4X:
public static short _numberofdigits(long _n) throws Exception {
short _i = (short)0;
long _p = 0L;
_i = (short) (1);
_p = (long) (10);
while (!(_n%_p==_n)) {
_p = (long) (_p*10);
_i = (short) (_i+1);
}
;
if (true) return _i;
return (short)0;
}
You could write a clean Java function and call it from a library:
B4X:
public static short numberofdigits(long n) {
short i = 1;
long p = 10L;
while (n % p != n) {
p *= 10;
++i;
}
return i;
}