Verwenden Sie Log
int length = (int) (Math. log10(number) + 1)
Obnoxious Opossum
int length = (int) (Math. log10(number) + 1)