When I create a loop to subtract .1 from a variable with a value of 1, the output after a few rounds results in a long float point number with extra digits at the end. Why am I getting the following results instead of the results that should be expected?
var x = 1;
for (var y = 0; y < 10; y++) {
x-=.1;
console.log(x);
}
And the result giving by the console output:
0.9
0.8
0.7000000000000001
0.6000000000000001
0.5000000000000001
0.40000000000000013
0.30000000000000016
0.20000000000000015
0.10000000000000014
1.3877787807814457e-16
However when I substract .3 from 1 the console output gives me the expected .7 value. Is this a browser specific issue with JavaScript implementation?