Java中的浮点型
Jihongchang(讨论 | 贡献)2022年11月12日 (六) 07:03的版本
怎样查看浮点型的二进制形式
public class Test2 {
public static void main(String[] args) {
int intBits = Float.floatToIntBits(12345.12346f); //Bit Representation of the Float
System.out.println(intBits); //1178657918
System.out.println(Integer.toBinaryString(intBits));
}
}
1178657918
1000110010000001110010001111110
Float.floatToIntBits(float value) 方法返回的 int 型数据,就是 float 输入参数的二进制形式转换成对应的十进制值。