//0.3*1==0.3 结果:true System.out.println("0.3*1==0.3 结果:" + (0.3 * 1 == 0.3)); //0.1*3==0.3 结果:false System.out.println("0.1*3==0.3 结果:" + (0.1 * 3 == 0.3)); //0.2 * 3 == 0.6 结果:false System.out.println("0.2 * 3 == 0.6 结果:" + (0.2d * 3d == 0.6d)); //0.3 * 2 == 0.6 结果:true System.out.println("0.3 * 2 == 0.6 结果:" + (0.3d * 2d == 0.6d)); //0.2 * 3 <= 0.6 结果:false System.out.println("0.2 * 3 <= 0.6 结果:" + (0.2d * 3d <= 0.6d)); //0.3 * 2 >= 0.6 结果:true System.out.println("0.3 * 2 >= 0.6 结果:" + (0.3d * 2d >= 0.6d)); //2 * 3 == 6 结果:true System.out.println("2 * 3 == 6 结果:" + (2 * 3 == 6)); //3 * 2 == 6 结果:true System.out.println("3 * 2 == 6 结果:" + (3 * 2 == 6)); BigDecimal t= BigDecimal.valueOf(0.3); BigDecimal t2= BigDecimal.valueOf(0.3); System.out.println("t 结果:" + t); //t.equals(t2) 结果:true System.out.println("t.equals(t2) 结果:" + (t.equals(t2) ));
标签:JAVA,结果,0.3,System,0.6,浮点,println,BUG,out From: https://www.cnblogs.com/cvol/p/16931347.html