when Double converts large numbers, there is a loss of precision or an error. For example, an error occurs when a number of 18 or more digits exceeds 100000000000000000. The problem can be solved by using BigDecimal or BigInteger, and the maximum value of Double is also much higher than this. Want to know why this is the case with Double?
NumberFormat nf = NumberFormat.getInstance();
nf.setGroupingUsed(false);
System.out.println(nf.format(Double.valueOf("100000000000000000")));//100000000000000000
System.out.println(nf.format(Double.valueOf("100000000000000001")));//100000000000000000
System.out.println(nf.format(Double.parseDouble("100000000000000216")));//100000000000000224
System.out.println(new BigDecimal("100000000000000216"));//100000000000000216