This question has already been answered:
Why is the value of the counter itself incorrectly displayed and the accuracy at run time goes away?
public class DoubleFor { public static void main(String[] args) { for (double d = 0.1; d <= 1; d += 0.1 ){ System.out.println("d = " + d); } } }
compilation:
d = 0.1
d = 0.2
d = 0.300000000000004
d = 0.4
d = 0.5
d = 0.6
d = 0.7
d = 0.7999999999999999
d = 0.8999999999999999
d = 0.9999999999999999Process finished with exit code 0
BigDecimal- Sergey