Created
August 28, 2019 13:03
-
-
Save thekalinga/0bfabc816a30765555708f57212b8f88 to your computer and use it in GitHub Desktop.
Get number of digits of a number in java8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int getNumOfDigits(int number) { | |
int numOfDigits = 0; | |
int remainder = number; | |
do { | |
numOfDigits++; | |
remainder = remainder / 10; | |
} while (remainder > 0); | |
return numOfDigits; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment