当前位置: 技术问答>java相关
这个程序有点问题?请教!
来源: 互联网 发布时间:2015-10-04
本文导语: public class A{ 程序: static float c; static float d; static float x; public static void main(String argv[]){ c=1234.0F/0.0F; d=(float)java.lang.Math.sqrt(-1.0); x=Float.MIN_VALUE/Float.MAX_VALUE; System.out.println(c); System.out.println(d); System.out.printl...
public class A{
程序:
static float c;
static float d;
static float x;
public static void main(String argv[]){
c=1234.0F/0.0F;
d=(float)java.lang.Math.sqrt(-1.0);
x=Float.MIN_VALUE/Float.MAX_VALUE;
System.out.println(c);
System.out.println(d);
System.out.println(x);
}
}
为什么c等于Infinity?d等于NaN?java中Infinity 和NaN具体描述是什么?
程序:
static float c;
static float d;
static float x;
public static void main(String argv[]){
c=1234.0F/0.0F;
d=(float)java.lang.Math.sqrt(-1.0);
x=Float.MIN_VALUE/Float.MAX_VALUE;
System.out.println(c);
System.out.println(d);
System.out.println(x);
}
}
为什么c等于Infinity?d等于NaN?java中Infinity 和NaN具体描述是什么?
|
java.lang.Float
field
INFINITY是无穷大
NaN就是Not a Number
POSITIVE_INFINITY
public static final float POSITIVE_INFINITY
The positive infinity of type float. It is equal to the value returned by Float.intBitsToFloat(0x7f800000).
NEGATIVE_INFINITY
public static final float NEGATIVE_INFINITY
The negative infinity of type float. It is equal to the value returned by Float.intBitsToFloat(0xff800000).
NaN
public static final float NaN
The Not-a-Number (NaN) value of type float. It is equal to the value returned by Float.intBitsToFloat(0x7fc00000).
field
INFINITY是无穷大
NaN就是Not a Number
POSITIVE_INFINITY
public static final float POSITIVE_INFINITY
The positive infinity of type float. It is equal to the value returned by Float.intBitsToFloat(0x7f800000).
NEGATIVE_INFINITY
public static final float NEGATIVE_INFINITY
The negative infinity of type float. It is equal to the value returned by Float.intBitsToFloat(0xff800000).
NaN
public static final float NaN
The Not-a-Number (NaN) value of type float. It is equal to the value returned by Float.intBitsToFloat(0x7fc00000).
|
NaN表示非数字
Infinity表示无穷大。
Infinity表示无穷大。
|
Infinity就是超出了float或double所能表示的最大上限。
NaN就是Not A Number
NaN就是Not A Number
|
Infinity 是无穷大 当0数据类型是Float或Double时 并且做除数会出现这样的现象 如果是其他类型编译出错
NAN 就是说一个数既(NOT A NUMBER)
NAN 就是说一个数既(NOT A NUMBER)