CODE:
public class Test {
public static void main(String[] args) {
System.out.println("Exponent loop:");
for(int i=1; i<10; ++i)
System.out.println(Math.pow(0.1, i));
System.out.println("\nMultiplication loop:");
double a = 1;
for(int i=1; i<10; ++i){
a *= 0.1;
System.out.println(a);
}
}
}
OUTPUT:
Exponent loop:
0.1
0.010000000000000002
0.0010000000000000002
1.0000000000000002E-4
1.0000000000000003E-5
1.0000000000000004E-6
1.0000000000000004E-7
1.0000000000000004E-8
1.0000000000000005E-9
Multiplication loop:
0.1
0.010000000000000002
0.0010000000000000002
1.0000000000000003E-4
1.0000000000000004E-5
1.0000000000000004E-6
1.0000000000000005E-7
1.0000000000000005E-8
1.0000000000000005E-9
WHY ??