I have a homework assignment where I need to do three-way conversion between decimal, binary and hexadecimal. The function I need help with is converting a decimal into a he
Another possible solution:
public String DecToHex(int dec){ char[] hexDigits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; String hex = ""; while (dec != 0) { int rem = dec % 16; hex = hexDigits[rem] + hex; dec = dec / 16; } return hex; }