Skip to content

Instantly share code, notes, and snippets.

@SIRHAMY
Last active August 29, 2015 13:56
Show Gist options
  • Save SIRHAMY/9087140 to your computer and use it in GitHub Desktop.
Save SIRHAMY/9087140 to your computer and use it in GitHub Desktop.
Converts a base 10 integer to a hexadecimal string of ASCII characters.
public static String itostrx(int hex)
{
String result = "";
String[] hexes = {"0", "1", "2", "3", "4","5","6","7","8","9","A",
"B","C","D","E","F"};
while(hex >= 0){
if(hex < 16){
result = hexes[hex] + result;
break;
}
result = hexes[hex%16] + result;
hex/=16;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment