Displayed precision of Java floating-point
问题 If we run the following code: float f = 1.2345678990922222f; double d = 1.22222222222222222222d; System.out.println("f = " + f + "\t" + "d = " + d); it prints: f = 1.2345679 d = 1.2222222222222223 The long tail in the literal 1.2345678990922222 is ignored but the long tail in 1.22222222222222222222 is not (the last decimal digit in the variable d becomes 3 instead of 2). Why? 回答1: The number of digits you see when a float or a double is printed is a consequence of Java’s rules for default