I have a simple code here, however it has not any division or complicated multiplying.
for ( double i=.1; i<=1; i+=.1) {
System.out.println(i);
}
But in some cases value of i
is not accurate, e.g. .79999999
or .600000001
.
Why did this happen? How can I change this code that becomes accurate?