Android Binary to Hex Convert binaryToHex(int binary)

Here you can find the source of binaryToHex(int binary)

Description

binary To Hex

Declaration

public static char binaryToHex(int binary) 

Method Source Code

//package com.java2s;

public class Main {

    public static char binaryToHex(int binary) {
        char ch = ' ';
        switch (binary) {
        case 0:/*  www.j  a  v a2  s .c  o  m*/
            ch = '0';
            break;
        case 1:
            ch = '1';
            break;
        case 2:
            ch = '2';
            break;
        case 3:
            ch = '3';
            break;
        case 4:
            ch = '4';
            break;
        case 5:
            ch = '5';
            break;
        case 6:
            ch = '6';
            break;
        case 7:
            ch = '7';
            break;
        case 8:
            ch = '8';
            break;
        case 9:
            ch = '9';
            break;
        case 10:
            ch = 'a';
            break;
        case 11:
            ch = 'b';
            break;
        case 12:
            ch = 'c';
            break;
        case 13:
            ch = 'd';
            break;
        case 14:
            ch = 'e';
            break;
        case 15:
            ch = 'f';
            break;
        default:
            ch = ' ';
        }
        return ch;
    }
}

Related

  1. bt4ToHex(String binary)