Character.digit
Class Overview | Class Members |
This Package |
All Packages
public static int digit( char ch,
int radix )
Parameters
- ch
- the character to be converted.
- radix
- the radix.
Returns
the numeric value represented by the character in the
specified radix.
Description
Returns the numeric value of the character ch in the
specified radix.
If the radix is not in the range MIN_RADIX <=
radix <= MAX_RADIX or if the
value of ch is not a valid digit in the specified
radix, -1 is returned. A character is a valid digit
if at least one of the following is true:
- The method isDigit is true of the character
and the Unicode decimal digit value of the character (or its
single-character decomposition) is less than the specified radix.
In this case the decimal digit value is returned.
- The character is one of the uppercase Latin letters
'A' through 'Z' and its code is less than
radix + 'A' - 10.
In this case, ch - 'A' + 10
is returned.
- The character is one of the lowercase Latin letters
'a' through 'z' and its code is less than
radix + 'a' - 10.
In this case, ch - 'a' + 10
is returned.
See Also
forDigit, isDigit