PFB an example code snippet illustrating the issue:
var x=0.323;
var cumulativeVal = 0;
for(i=0;i<30;i++){
cumulativeVal = cumulativeVal + x;
console.log(cumulativeVal);
}
The result of the above computation is
0.323
0.646
0.9690000000000001
1.292
1.615....
4.845000000000001
5.168000000000001
5.491000000000001
5.814000000000002....
9.690000000000007
Note that an extra decimal value is getting added. I do understand that this has something to do with precision of values in javascript. But can anyone explain?