What == 3 * 0.1 0.3 will be returned? true or false?

Transfer: https://www.cnblogs.com/areyouready/p/7802725.html
false, because some floating point numbers can not be completely accurate representation out

        public static void main(String[] args) {
        System.out.println(3 * 0.1);
        System.out.println(4 * 0.1);
        System.out.println(3 * 0.1 == 0.3);
        System.out.println(13 * 0.1 == 1.3);
        System.out.println(9 * 0.1 == 0.9);
        System.out.println(3 * 0.1 / 3);
    }    

        结果是:
        0.30000000000000004
        0.4
        false
        true
        true
        0.10000000000000002

Guess you like

Origin www.cnblogs.com/HelloXTF/p/12121027.html