Java Hex Calculate toHexDigit(char ch)

Here you can find the source of toHexDigit(char ch)

Description

to Hex Digit

License

Apache License

Declaration

private static int toHexDigit(char ch) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static int toHexDigit(char ch) {
        if ((ch <= '9') && (ch >= '0')) {
            return (ch - '0');
        }//w w  w.j av a  2s.  c om
        if ((ch >= 'a') && (ch <= 'f')) {
            return ((ch - 'a') + 10);
        }
        if ((ch < 'A') || (ch > 'F')) {
            throw new IllegalArgumentException("Illegal hexadecimal charcter + " + ch);
        }
        return ((ch - 'A') + 10);
    }
}

Related

  1. toHexCharFromBin(final String bin)
  2. toHexChars(byte[] bs)
  3. toHexChars(byte[] bytes)
  4. toHexChars(final int b)
  5. toHexDec(byte[] bytes)
  6. toHexDigit(char ch, int index)
  7. toHexDigit(int d)
  8. toHexDigit(int d)
  9. toHexDigit(int h)