class ShuZuTest5
{
public static void main(String[] args)
{
toHex(60);
}
//十进制转二进制
public static void toBin(int num)
{
while (num>0)
{
System.out.println(num%2);
num = num/2;
}
}
//十进制转十六进制
public static void toHex(int num)
{
for (int x=0;x<8;x++ )
{
int temp = num & 15;
if (temp>9)
System.out.println((char)(temp-10+'A'));
else
System.out.println(temp);
num = num >>>4;
}
}
}
|
|