Here you can find the source of decimal2hex(int d)
public static String decimal2hex(int d)
//package com.java2s; //License from project: LGPL public class Main { private static final String digits = "0123456789ABCDEF"; public static String decimal2hex(int d) { if (d == 0) return "0"; StringBuilder hex = new StringBuilder(); while (d > 0) { int digit = d % 16; hex.insert(0, digits.charAt(digit)); d = d / 16;/*from ww w . ja v a 2 s . c o m*/ } return hex.toString(); } }