Java, jak znaleźć długość int
int x = 1234;
int lengthOfInt = String.valueOf(x).length(); //convert integer to String
//and get length of the String
ofroog
int x = 1234;
int lengthOfInt = String.valueOf(x).length(); //convert integer to String
//and get length of the String
int n = 1000;
int length = (int)(Math.log10(n)+1);
//NB: only valid for n > 0
int numOfDigits = ((int) Math.floor(Math.log10(number))) + 1
int length = (int) (Math.log10(number) + 1);