Java Hex to Int convertHexDigitAsInt(char c)

Here you can find the source of convertHexDigitAsInt(char c)

Description

convert Hex Digit As Int

License

LGPL

Declaration

public static int convertHexDigitAsInt(char c) 

Method Source Code

//package com.java2s;
/*//from  w  w  w.  j  a v  a 2s .  com
 * JLib - Publicitas Java library v1.2.0.
 *
 * Copyright (c) 2005, 2006, 2007, 2008, 2009 Publicitas SA.
 * Licensed under LGPL (LGPL-LICENSE.txt) license.
 */

public class Main {
    public static int convertHexDigitAsInt(char c) {
        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 0;
    }
}

Related

  1. convertHexBytesToInt(byte[] hex)
  2. convertHexStringToInt(String hex)
  3. convertHexStringToInt(String hexString)
  4. convertHexToDec(String in)
  5. convertHexToInt(String hex)