0
How to find a length of an integer
we really have to convert the integer into a string??i dont understand why all of them are doing it.......
6 Respuestas
+ 5
int nb = 1;
int bit = 1; //let's say your number is n
while(bit <= n){
++nb;
bit *= 10;
}
+ 4
An integer does not have a length property or a method that returns the length or number of digits that the number has. Most will convert the number to a String and then use the String length to get the number of digits the number has. The other option is to use some mathematical method that will return the number of digits that a number has. This is what the code I posted does in the getNumberOfDigits(int number) method.
+ 1
thank u sir now i understand that.......
0
give me a simple answer im just a beginnner this code is difficult for me sir....
0
find the no. of digits