Java Utililty Methods Digit From

List of utility methods to do Digit From

  1. HOME
  2. Java
  3. D
  4. Digit From

Description

The list of methods to do Digit From are organized into topic(s).

Method

int toDigit(char c)
to Digit
if (c >= '0' && c <= '9')
 return c - '0';
if (c >= 'a' && c <= 'f')
 return c - 'a' + 10;
if (c >= 'A' && c <= 'F')
 return c - 'A' + 10;
return -1;
int toDigit(char ch)
Converts the character to a digit, throws an IllegalStateException if it isn't a valid digit.
if (('0' <= ch) && (ch <= '9')) {
 return ch - '0';
throw new IllegalStateException();
int toDigit(char ch, int index)
to Digit
int digit = Character.digit(ch, 16);
if (digit == -1)
 throw new IllegalStateException("Illegal hexadecimal charcter " + ch + " at index " + index);
return digit;
int toDigit(final boolean bit)
Converts a boolean into a digit.
return (bit) ? TRUE : FALSE;
int toDigit(final char ch, final int index)
to Digit
final int digit = fastDigit(ch);
if (digit == -1) {
 throw new RuntimeException("Illegal hexadecimal charcter " + ch + " at index " + index);
return digit;
int toDigit(final char ch, final int index)
Converts a hexadecimal character to an integer.
final int digit = Character.digit(ch, 16);
if (digit == -1) {
 throw new IllegalArgumentException("Illegal hexadecimal character " + ch + " at index " + index);
return digit;
char toDigit(final int value)
to Digit
assert 0 <= value && value < RADIX;
return Character.forDigit(value, RADIX);
int toDigit(int c)
to Digit
if (c > '9') {
 if (c > 'F') {
 if (c >= 'a' && c <= 'f') {
 return c - 'a' + 10;
 } else if (c >= 'A') {
 return c - 'A' + 10;
} else if (c >= '0') {
 return c - '0';
throw new IllegalArgumentException();
char toDigit(int i)
Converts a digit to its char representation.
if (i >= 0 && i <= 9) {
 return (char) ('0' + i);
} else if (i >= 10 && i < 36) {
 return (char) ('A' + i - 10);
} else {
 throw new IllegalArgumentException("i must be at least 0 and no greater than 35. Invalid i: " + i);
char toDigit(int n)
Returns the hex digit corresponding to a number n, from 0 to 15.
try {
 return hexDigits[n];
} catch (ArrayIndexOutOfBoundsException e) {
 throw new IllegalArgumentException(n + " is out of range for a hex digit");


AltStyle によって変換されたページ (->オリジナル) /