|
Is decimal to hexadecimal?
public class DecToHex {
public static char table[]={'0','1','2','3','4','5','6','7','8','9','A ','B','C','D','E','F'};
public static void main(String[] args)
{
int sourceDec=Integer.parseInt(args[0]);
int length=0;
int[] digits=new int[20];
while(sourceDec>=16)
{
digits[length++]=sourceDec%16;
sourceDec/=16;
}
digits[length]=sourceDec;
for(int i=length;i>=0;i--)
{
System.out.print(table[digits[i]]);
}
}
} |
|