JAVA问题总结之4--各大数据类型能存的最大最小值

问题4:JAVA各大数据类型能存的最大值和最小值:包括char,byte,int,long,float,double等.float和double分别用科学计数法和非科学计数法输出。

JAVA问题总结之4--各大数据类型能存的最大最小值_第1张图片


下面为代码和输出结果:

package p1;

public class test3 {
	public static void main(String[] args) {
		
		System.out.println("\nCharacter:");
		System.out.printf("Double.MIN_VALUE = %h\n",Character.MIN_VALUE);
		System.out.printf("Double.MAX_VALUE = %h\n",Character.MAX_VALUE);
		System.out.println("\nByte:");
		System.out.println("Byte.MIN_VALUE = " + Byte.MIN_VALUE);  
        System.out.println("Byte.MAX_VALUE = " + Byte.MAX_VALUE); 
        System.out.println("\nShort:");
		System.out.println("Short.MIN_VALUE = " + Short.MIN_VALUE);  
        System.out.println("Short.MAX_VALUE = " + Short.MAX_VALUE); 
        System.out.println("\nInteger:");
        System.out.println("Integer.MIN_VALUE = " + Integer.MIN_VALUE);  
        System.out.println("Integer.MAX_VALUE = " + Integer.MAX_VALUE);  
        System.out.println("\nLong:");
        System.out.println("Long.MIN_VALUE = " + Long.MIN_VALUE);  
        System.out.println("Long.MAX_VALUE = " + Long.MAX_VALUE);  
        System.out.println("\n");
        System.out.println("\nFloat科学计数法:");
        System.out.println("Float.MIN_VALUE = " + Float.MIN_VALUE);  
        System.out.println("Float.MIN_NORMAL = " + Float.MIN_NORMAL);  
        System.out.println("Float.MAX_VALUE = " + Float.MAX_VALUE);  
        System.out.println("Float非科学计数法:");
        System.out.printf("Float.MIN_VALUE = %f\n",Float.MIN_VALUE);
        System.out.printf("Float.MIN_VALUE = %f\n",Float.MIN_NORMAL);
        System.out.printf("Float.MAX_VALUE = %f\n",Float.MAX_VALUE);

        System.out.println("\nDouble科学计数法:");
        System.out.println("Double.MIN_VALUE = " + Double.MIN_VALUE);
        System.out.println("Double.MAX_VALUE = " + Double.MAX_VALUE);  
        System.out.println("Double非科学计数法:");
        System.out.printf("Double.MIN_VALUE = %f\n",Double.MIN_VALUE);
        System.out.printf("Double.MAX_VALUE = %f\n",Double.MAX_VALUE);
	}
}

 
  

输出结果:

Character:
Double.MIN_VALUE = 0
Double.MAX_VALUE = ffff

Byte:
Byte.MIN_VALUE = -128
Byte.MAX_VALUE = 127

Short:
Short.MIN_VALUE = -32768
Short.MAX_VALUE = 32767

Integer:
Integer.MIN_VALUE = -2147483648
Integer.MAX_VALUE = 2147483647

Long:
Long.MIN_VALUE = -9223372036854775808
Long.MAX_VALUE = 9223372036854775807



Float科学计数法:
Float.MIN_VALUE = 1.4E-45
Float.MIN_NORMAL = 1.17549435E-38
Float.MAX_VALUE = 3.4028235E38
Float非科学计数法:
Float.MIN_VALUE = 0.000000
Float.MIN_VALUE = 0.000000
Float.MAX_VALUE = 340282346638528860000000000000000000000.000000

Double科学计数法:
Double.MIN_VALUE = 4.9E-324
Double.MAX_VALUE = 1.7976931348623157E308
Double非科学计数法:
Double.MIN_VALUE = 0.000000
Double.MAX_VALUE = 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000

 环境: 
  

系统:win8.1 64位 
IDE:eclipse Version: Mars Release (4.5.0) 
JDK:version 1.7.0_79  


 
  




你可能感兴趣的:(JAVA)