Java中的浮点型

来自姬鸿昌的知识库
Jihongchang讨论 | 贡献2022年11月12日 (六) 06:58的版本 (建立内容为“=== 怎样查看浮点型的二进制形式 === <syntaxhighlight lang="java"> public class Test2 { public static void main(String[] args) { int intB…”的新页面)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索

怎样查看浮点型的二进制形式

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));

    }

}