有人可以逐步解释1.0E-12F
如何转换为二进制代码101011100011001011110011001100
吗?谢谢!
测试代码:
public class Demo {
public static void main(String[] args) throws Exception {
float c = 1.0E-12F;
System.out.println(Integer.toBinaryString(Float.floatToIntBits(c)));
String myString = "101011100011001011110011001100";
int intBits = Integer.parseInt(myString, 2);
float myFloat = Float.intBitsToFloat(intBits);
System.out.println(myFloat);
}
}
结果:
101011100011001011110011001100
1.0E-12
最佳答案
阅读Wikipedia上32位浮点的描述。
因此,101011100011001011110011001100
是:
0 01010111 00011001011110011001100
符号:0 =正
指数:010101112 = 8710⇒287-127 = 2-40≈9.094947e-13
分数:1.000110010111100110011002≈1.099511610
结果:1.0995116 * 9.094947e-13≈1.0e-12