Why 0.1 + 0.1 == 0.2?
问题 This is concerning Java. From what I've understood, 0.1 cannot be perfectly represented by Java because of binary representations. That makes 0.1 + 0.1 + 0.1 == 0.3 false. However, why does 0.1 + 0.1 == 0.2 gives true? 回答1: 0.1 cannot be perfectly represented by Java because of binary representations. That makes 0.1 + 0.1 + 0.1 == 0.3 false. That is not the entire reason why the equality is false, although it is part of it. 0.3 is not exactly 3/10 either. It so happens that 0.2 is exactly