I'm trying to make a simple summation of an array of 10 numeric elements.
I get a totally incorrect result, which only occurs with an array of certain values, otherwise works well.
var sum = 0;
var values = [14, -1.4, -1.4, -1.4, -1.4, -1.4, -1.4, -1.4, -1.4, -1.4, -1.4];
for (var i = 0; i < values.length; i++) {
var v = values[i];
sum += v;
}
console.log(sum);
The expected result is 0, but I get oddly -2.22!
At other times, I have achieved results with so many decimal places, which I had to round up.
But in this case, with these numbers, that kind of bug is absurd.