Added isNumber for characters
This commit is contained in:
parent
740087f2cf
commit
c8f2bef1d9
@ -39,6 +39,17 @@ class MathUtil {
|
||||
return isNumber(string, 19);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the character is a number
|
||||
*
|
||||
* @return true if it's a number, false otherwise
|
||||
*/
|
||||
public static
|
||||
boolean isNumber(final char character) {
|
||||
// way faster than Character.isDigit()
|
||||
return character >= '0' && character <= '9';
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if the string is a number
|
||||
*
|
||||
@ -72,6 +83,7 @@ class MathUtil {
|
||||
|
||||
for (; i < length; i++) {
|
||||
char c = string.charAt(i);
|
||||
// way faster than Character.isDigit()
|
||||
if (c < '0' || c > '9') {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user