知识点补充1:浮点数在内存中的表示方式
1.4E-45~3.4E+38 , -1.4E-45~-3.4E+38 。用二进制的指数形式表示一个浮点数的格式,如:
在JDK文档中查找Float. intBitsToFloat的说明
If the argument is 0x7f800000, the result is positive infinity.
If the argument is 0xff800000, the result is negative infinity.
In all other cases, let s, e, and m be three values that can be computed from the argument:
int s = ((bits >> 31) == 0) ? 1 : -1;
int e = ((bits >> 23) & 0xff);
int m = (e == 0) ?
(bits & 0x7fffff) << 1 :
(bits & 0x7fffff) | 0x800000;
编程试验代码如下:
System.out.println(Float.intBitsToFloat(0x7f800000));//正的无穷大;显示结果Infinity;
System.out.println(Float.intBitsToFloat(0x7f7fffff));//表示的最大的数;显示结果3.402823E38;
System.out.println(Float.intBitsToFloat(0x00000001));//表示最小的正数
System.out.println(Float.intBitsToFloat(0x7f800001));//数据溢出;显示结果NaN;
System.out.println(Float.intBitsToFloat(0xff800000));//负的无穷大;显示结果-Infinity;
System.out.println(Float.intBitsToFloat(0xff800001));//数据溢出;显示结果NaN;
System.out.println(Float.intBitsToFloat(0xff7fffff));//表示最小的负数;显示结果-3.402823E38;
表示最小的正数0x00000001的计算过程: s就是1,e为0,有效位左移后变为2,即m=2,
数为:1*2*2-150=1.4*e-45
同样0x50000000,是正数,s为1,对应指数e为160,有效位为16进制0x800000,即223,
数为:1*22*210=8589934592
总结,在实验过程中,自己将Lessen2的类名错打成Lesson,一直还没有发现,总以为设置classpath的路径不对,更改了好多次设置,自己用一两个小时来纠错,最好都群里让人给帮忙看来下才发现问题,唉,以后一定要仔细,一层层审问题。
还是老师提醒的对,“计算机不会犯错的,程序出了问题多半是人的问题”