package com.Test;
public class Test1 {
public static String decToHex(long dec) { String hex = ""; while(dec != 0) { String h = Long.toString(dec & 0xff, 16); if((h.length() & 0x01) == 1) h = '0' + h; hex = hex + h; dec = dec >> 8; } return hex; } public static String decToHex1(String s) { String hex = ""; for(int i=0;i<s.length()/2;i++){ String h = s.substring(i*2, i*2+2); System.out.println(h); hex =h+hex; } long dec = Long.parseLong(hex, 16); hex = Long.toString(dec); return hex ; }//0f8701
public static void main(String args[]){// long s = 100111; // String ss = decToHex(s); // System.out.println(Long.toString(s&0xff,16)); // System.out.println(ss); // System.out.println(decToHex1(“0f8701”));
}}
