The basic data types and data test

/ **
 * <the p-> ClassName: DataTypeTest </ the p->
 * <the p-> the Description: </ the p-> 
 * @author gangye
 * @date 1:41:41 2018 Nian 12 4 afternoon 
 * /

{class DataTypeTest public
    public static void main (String [] args) {
        // boolean: true and false indicates real things, only two values, to true, to false
        Boolean = In Flag to true;
        Boolean = FLAG2 to false;
        
        / **** ************** ******** non-integral type /
        @ character type
        char ch = 'and'; // only single quotes assignment
        
        using the ASCII code // assignment
        char = 65 mm;
        System.out.println ( "mm =" + mm);
        
        // use unicode code assignment
        char cm & lt = '\ u6211';
        System.out.println ( "cm & lt uncode the code:" + cm) ;
        
        // int
        int IA = 2147483647;
        
        // short integer
        short SA =. 11;
        
        // long
        long La = 1093109470L;
        
        // double
        DA = 30.2 Double;
        
        // single precision
        a float FA = 30.2f;
        
        System.out.println ( "int type range:" + of Integer.MIN_VALUE + "~" + Integer.MAX_VALUE);
        System.out.println ( "Short Type range: "+ Short.MIN_VALUE +" ~ "+ Short.MAX_VALUE);
        System.out.println (" Long range type: "of Long.MIN_VALUE + +" ~ "of Long.MAX_VALUE +);
        System.out.println (" type double range: "+ Double.MIN_VALUE +" ~ "+ Double.MAX_VALUE);
        System.out.println (" a float type range: "+ Float.MIN_VALUE +" ~ "+ Float.MAX_VALUE);
    }
}

operation result:

 

{class FloatTest public
    public static void main (String [] args) {
        a float FA = 5.224563468328f;
        System.out.println ( "FA:" + FA);
        
        Double DA = 0.0;
        
        // infinite
        double db = Double.NEGATIVE_INFINITY;
        FC = Float.NEGATIVE_INFINITY a float;
        // db is equal Analyzing FC
        // == number is determined using the second value are equal
        System.out.println (db == FC);
        System.out.println (DA / DA); // to give a number of non-
        System.out.println (Float.NaN has);
        System.out.println (DA / DA Float.NaN has ==); // number of two non-true results can not be obtained, the two numbers can not be compared non
        
        System .out.println (10.0 / 0); // get positive infinity
        System.out.println (10.0 / 0 == 12.0 / 0); // two positive infinite value may be equal
        
        System.out.println (-9.0 / 0);
        System.out.println (-8 / 0.0);
        System.out.println (-9.0 / 0 == -. 8 / 0.0); // Likewise, two negative values may be equal to infinity
        
        / *
        // not an integer denominator 0, otherwise thrown
        System.out.println (-9/0);
        * /
        System.out.println ( "---------------------- ------- ");
        // define positive infinity or negative infinity can Double Float Double.POSITIVE_INFINITY as the class (positive infinity) Double.POSITIVE_INFINITY as (negative infinity)
        
        Double Double.POSITIVE_INFINITY as D1 =;
        Double D2 = Double.POSITIVE_INFINITY as;
        Double D3 = Double.NEGATIVE_INFINITY;
        System.out.println (d1-100000000); // add any non-positive infinity or infinity infinity
        System.out.println (d1 + d2); // add n plus infinity infinity or infinity
        System.out.println (d1 + d3); // add positive infinity minus infinity non number
        System.out.println (d1 * d2); // multiplied by the positive infinity plus infinity or positive infinity
        System.out.println (d1 * d3); // positive infinity minus infinity is multiplied by negative infinity
        System.out.println ( D1 / D3);
        System.out.println (D1 / D2); // number of non than infinity infinity
    }
}

operation result:

Published 14 original articles · won praise 19 · views 10000 +

Guess you like

Origin blog.csdn.net/xibei19921101/article/details/84788602