Java Hex Calculate toHexString(int b)

Here you can find the source of toHexString(int b)

Description

to Hex String

License

Open Source License

Declaration

public static final String toHexString(int b) 

Method Source Code

//package com.java2s;

public class Main {
    public static final String toHexString(int b) {
        return "" + toHexChar(b >> 4) + toHexChar(b);
    }//from w ww  .j ava  2  s.  co  m

    public static final char toHexChar(int b) {
        switch (0XF & b) {
        case 0xF:
            return 'F';
        case 0xE:
            return 'E';
        case 0xD:
            return 'D';
        case 0xC:
            return 'C';
        case 0xB:
            return 'B';
        case 0xA:
            return 'A';
        default:
            return (char) ('0' + (0xF & b));

        }
    }
}

Related

  1. toHexString(final byte[] fieldData)
  2. toHexString(final byte[] raw)
  3. toHexString(final int i)
  4. toHexString(final int value)
  5. toHexString(final long num, final char paddingChar, int min, int max)
  6. toHexString(int b)
  7. toHexString(int bits, int value)
  8. toHexString(int decimal, int stringLength)
  9. toHexString(int decimal, int stringLength)