Float isNaN() 样例

来源:互联网 发布:知轩藏书雪中悍刀行 编辑:程序博客网 时间:2024/05/20 01:37

/*
* boolean isNaN(float f) static method checks whether the agrument
* primitive float value is Not-a-Number value or not. It return true if
* the specified argument is Not-a-Number value, false otherwise.
*/
float f = (float) Math.sqrt(-10);
System.out.println(f);
boolean b1 = Float.isNaN(f);
System.out.println(b1);

    /*     * boolean isNaN() instance method checks whether the Float object is     * Not-a-Number value or not. It return true if the object is     * Not-a-Number value, false otherwise.     */    Float fObj = new Float(f);    boolean b2 = fObj.isNaN();    System.out.println(b2);
0 0
原创粉丝点击