Java Hex Calculate toHexChar(int digit)

Here you can find the source of toHexChar(int digit)

Description

'0' - '9', 'A', 'B', 'C', 'D', 'E', 'F'

License

Open Source License

Declaration

private static char toHexChar(int digit) 

Method Source Code

//package com.java2s;
/*//ww w  . j ava 2s .c o  m
 * Copyright 2001-2008 Aqris Software AS. All rights reserved.
 * 
 * This program is dual-licensed under both the Common Development
 * and Distribution License ("CDDL") and the GNU General Public
 * License ("GPL"). You may elect to use one or the other of these
 * licenses.
 */

public class Main {
    /** '0' - '9', 'A', 'B', 'C', 'D', 'E', 'F' */
    private static char toHexChar(int digit) {
        digit &= 0x0F; // last four bits
        if (digit < 10) {
            return (char) ('0' + digit);
        }

        return (char) (('A' - 10) + digit);
    }
}

Related

  1. toHexBytes(byte[] data)
  2. toHexBytes(byte[] toBeConverted)
  3. toHexChar(byte[] bArray)
  4. toHexChar(char ch, StringBuffer sb)
  5. toHexChar(int b)
  6. toHexChar(int digitValue)
  7. toHexChar(int digitValue)
  8. toHexChar(int i)
  9. toHexChar(int i)