java中的NaN

来源:互联网 发布:信息过滤软件 编辑:程序博客网 时间:2024/06/10 10:12
public class TestNaN {             public static void main(String args[]){                      // 在double 和 float 类型中,有NaN值           double a =0 , b= 0 ,c;           c = a/(a+b);           System.out.println(c);                      // 在int 和 long 类型中,没有NaN值,解除注释,此处会抛异常 ---  / by zero   //      int a =0 , b= 0 ,c;   //      c = a/(a+b);   //      System.out.println(c);                      //**** NaN与任何数比较均返回false ****        if( (0 > c) || (0 == c) || (0 < c)){               System.out.println("NaN compared with 0 is not always false.");           }else{               System.out.println("NaN compared with 0 is always false!");           }       }   }  

0 0