Java Hex Calculate toHexDigit(int d)

Here you can find the source of toHexDigit(int d)

Description

to Hex Digit

License

Open Source License

Declaration

private static char toHexDigit(int d) 

Method Source Code

//package com.java2s;
/*//w  w w. j  a  v a 2s.c o  m
 * Copyright (c) Nmote d.o.o. 2003-2015. All rights reserved.
 * See LICENSE.txt for licensing information.
 */

public class Main {
    private static char toHexDigit(int d) {
        switch (d) {
        case 0:
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
            return (char) ('0' + d);
        case 10:
        case 11:
        case 12:
        case 13:
        case 14:
        case 15:
            return (char) ('a' + d - 10);
        default:
            throw new IllegalArgumentException("Not a hex digit: " + d);
        }
    }
}

Related

  1. toHexChars(final int b)
  2. toHexDec(byte[] bytes)
  3. toHexDigit(char ch)
  4. toHexDigit(char ch, int index)
  5. toHexDigit(int d)
  6. toHexDigit(int h)
  7. toHexDigit(int i)
  8. toHexDigit(int number)
  9. toHexDigit(int value, int digitPosition)