????java????????????????????????????NAN??INFINITY??
????1??INFINITY??
???????????????????????????????????0?????????java????ν???????
????????????????????????У???????????0?????????????д???????????????????У?????????????????????????????Double??Float?е???塣
????Double??
????public static final double POSITIVE_INFINITY = 1.0 / 0.0;
????public static final double NEGATIVE_INFINITY = -1.0 / 0.0;
????Float??
????public static final float POSITIVE_INFINITY = 1.0f / 0.0f;
????public static final float NEGATIVE_INFINITY = -1.0f / 0.0f;
?????????Щ??????????????????
???????????????????漸??????
????Float??Double?е?????????????
???????????????0????????
????0????0????????????
????????????????????
???????????
????public static void main(String[] args) {
????float fPos=Float.POSITIVE_INFINITY;
????float fNeg=Float.NEGATIVE_INFINITY;
????double dPos=Double.POSITIVE_INFINITY;
????double dNeg=Double.NEGATIVE_INFINITY;
????//t1
????System.out.println(fPos==dPos);  //output: true
????System.out.println(fNeg==dNeg);  //output: true
????//t2
????System.out.println(fPos*0);  //output: NAN
????System.out.println(fNeg*0);  //output: NAN
????//t3
????System.out.println(fPos==(fPos+10000));  //output: true
????System.out.println(fPos==(fPos*10000));  //output: true
????System.out.println(fPos==(fPos/0));  //output: true
????//t4
????System.out.println(Double.isInfinite(dPos));  //output: true
????}
???????????
?????????漸????????????ó??Щ?????
????t1: Float?е??????Double?е????????????
????t2: ???????0???????NAN???????????
????t3: ???????0?????????????????????????????
??????ж??????????????INFINITY??????t4???????isInfinite??????
????2??NAN
????java?е?NAN???????????
????public static final double NaN = 0.0d / 0.0;
????NAN???????????????κ?????????????????????????????????ж??????????NAN???isNAN??????
????public static void main(String[] args) {
????double nan=Double.NaN;
????System.out.println(nan==nan);  //output: false
????System.out.println(Double.isNaN(nan));  //output: true
????}