Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 26, 2020 19:00
Show Gist options
  • Save parzibyte/5330e9de184b410ba319a2c5c456fa8a to your computer and use it in GitHub Desktop.
Save parzibyte/5330e9de184b410ba319a2c5c456fa8a to your computer and use it in GitHub Desktop.
public static String decimalAHexadecimal(int decimal) {
String hexadecimal = "";
String caracteresHexadecimales = "0123456789abcdef";
while (decimal > 0) {
int residuo = decimal % 16;
hexadecimal = caracteresHexadecimales.charAt(residuo) + hexadecimal; // Agregar a la izquierda
decimal /= 16;
}
return hexadecimal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment