进制数
package day2;
public class VarDemo {
//整数
public static void main(String[] args) {
// TODO Auto-generated method stub
//-128—–127
//编译错误 运行
byte a=-128;
//向控制台输出a
System.out.println(“十进制 “+a);//默认十进制(+为连接,输出a)
System.out.println("二进制 "+Integer.toBinaryString(a));//输出二进制
System.out.println("十六进制 "+Integer.toHexString(a)); //输出十六进制
System.out.println("八进制 "+Integer.toOctalString(a)); //输出八进制
System.out.println(Byte.MAX_VALUE);
System.out.println(Byte.MIN_VALUE);
//Short b=
System.out.println(Short.MIN_VALUE);
short max=Short.MAX_VALUE;
short min=Short.MIN_VALUE;
System.out.println("short十进制最大值"+max);
System.out.println("short十六进制最大值"+Integer.toHexString(max));
System.out.println("short二进制最大值"+Integer.toBinaryString(max));
System.out.println("short十进制最小值"+min);
System.out.println("short十六进制最小值"+Integer.toHexString(min));
System.out.println("short二进制最小值"+Integer.toBinaryString(min));
int Imax =Integer.MAX_VALUE;
int Imin =Integer.MIN_VALUE;
System.out.println("int十进制最大值"+max);
System.out.println("int十六进制最大值"+Integer.toHexString(Imax));
System.out.println("int二进制最大值"+Integer.toBinaryString(Imax));
System.out.println("int十进制最小值"+min);
System.out.println("int十六进制最小值"+Integer.toHexString(Imin));
System.out.println("int二进制最小值"+Integer.toBinaryString(Imin));
long lmax =Long.MAX_VALUE;
long lmin =Long.MIN_VALUE;
System.out.println("long十进制最大值"+max);
System.out.println("longl十六进制最大值"+Integer.toHexString(max));
System.out.println("long二进制最大值"+Integer.toBinaryString(max));
System.out.println("long十进制最小值"+min);
System.out.println("long十六进制最小值"+Integer.toHexString(min));
System.out.println("long二进制最小值"+Integer.toBinaryString(min));
}
}