java十進制轉換方法
/**
* Java內置的進制轉換
* @author Administrator
*
*/
public class RedixMain {
public static void main(String[] args){
/*十進制轉其餘進制*/
int TestNumber = 112;
/*十進制轉二進制*/
System.out.println(Integer.toBinaryString(TestNumber));
/*十進制轉16進制*/
System.out.println(Integer.toHexString(TestNumber));
/*十進制轉8進制*/
System.out.println(Integer.toOctalString(TestNumber));
/*其餘進制轉十進制*/
/*二進制轉十進制*/
System.out.println(Integer.parseInt("1110000", 2));
/*16進制轉十進制*/
System.out.println(Integer.parseInt("70", 16));
/*8進制轉十進制*/
System.out.println(Integer.parseInt("160", 8));
}
}