Here you can find the source of convertHexDigit(byte c)
Parameter | Description |
---|---|
c | An ASCII encoded character 0-9 a-f A-F |
public static byte convertHexDigit(byte c)
//package com.java2s; // are made available under the terms of the Eclipse Public License v1.0 public class Main { /**/* ww w . ja v a 2 s. co m*/ * @param c An ASCII encoded character 0-9 a-f A-F * @return The byte value of the character 0-16. */ public static byte convertHexDigit(byte c) { byte b = (byte) ((c & 0x1f) + ((c >> 6) * 0x19) - 0x10); if (b < 0 || b > 15) throw new NumberFormatException("!hex " + c); return b; } /** * @param c An ASCII encoded character 0-9 a-f A-F * @return The byte value of the character 0-16. */ public static int convertHexDigit(int c) { int d = ((c & 0x1f) + ((c >> 6) * 0x19) - 0x10); if (d < 0 || d > 15) throw new NumberFormatException("!hex " + c); return d; } }