//十进制——>二进制
public detoBi(int num)
{
    StringBuffer sb = new StringBuffer(); //StringBuffer是一个容器,可以存放数据
    while(num>0)
    {
        sb.append(num%2);     //此对象有个函数append():往容器中添加数据
        num = num/2;
    }
    System.out.println(sb.reverse()); //reverse():把容器中的字符倒序输出
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//十进制——>十六进制
public deToHex(int num)
{
    int temp;
    StringBuffer sb = new StringBuffer();
    while(num != 0)
    {
        temp = num&15;
        if(temp>9)
            sb.append((char)(temp-10+'A'));
        else
            sb.append(temp);
        num = num >>> 4;
    }
    System.out.println(sb.reverse());
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//转换通法(查表法)
trans(int num, int base, int offset)
{
    int[] arr = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',};
    StringBuffer sb = new StringBuffer();
      
    while(num != 0)
    {
        int temp = num & base;
        sb.append(arr[temp]);
        num >>> offset;
    }
      
    System.out.println(sb.reverse());
}