如果有不妥之处,请给予留言纠正,谢谢!本文仅限于学习。
1.进制间的转换
-
public class HexConversion
-
{
-
-
-
-
-
-
-
public static void main(String[] args)
-
{
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
System.out.printf("%x \n", 10);
-
-
-
-
-
-
-
-
-
-
-
System.out.println("数值:为18的十进制转二进制:"+Integer.toBinaryString(18));
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
String v1 = "10010";
-
System.out.println("数值:为10010的二进制转十进制:"+Long.parseLong(v1,2));
-
-
int r1 = (int)(0*Math.pow(2, 0)+1*Math.pow(2, 1)
-
+0*Math.pow(2, 2)+0*Math.pow(2, 3)+1*Math.pow(2, 4));
-
System.out.println("法二: 数值:为10010的二进制转十进制:"+r1);
-
-
-
-
-
-
-
-
-
-
System.out.println("数值:为18的十进制转八进制:"+Integer.toOctalString(18));
-
-
-
-
-
String v2 = "22";
-
System.out.println("数值:为22的八进制转十进制:"+Long.parseLong(v2,8));
-
-
int r2 = (int)(2*Math.pow(8, 0)+2*Math.pow(8, 1));
-
System.out.println("法二: 数值:为22的八进制转十进制:"+r2);
-
-
-
-
-
-
-
-
-
-
-
System.out.println("数值:为18的十进制转十六进制 :"+Integer.toHexString(18));
-
-
-
-
-
-
-
-
-
-
-
-
String v3 = "100 110 101 1";
-
-
}
-
-
}
2.位移运算详解