添加我从 CSV 中提取的数字时,这是我得到的日志文件:
var costs = Number(csvData[i][9].replace(",",".")); // need to replace , with . and
total_costs_overeenkomst=total_costs_overeenkomst+costs; // add variables
Logger.log("Kosten: "+costs);
Logger.log("Subtotaal:"+total_costs_overeenkomst);
这是日志,直到第 3 天,我得到一个奇怪的舍入错误:
Kosten:4.8
Subtotaal:4.8
Kosten:49.92
Subtotaal:54.72
Kosten:4.8
Subtotaal:59.519999999999996
Kosten:2.4
Subtotaal:61.919999999999995
Kosten:2.57
Subtotaal:64.49
Kosten:22.18
Subtotaal:86.66999999999999
Kosten:34.56
Subtotaal:121.22999999999999
Kosten:4.8
Subtotaal:126.02999999999999
为什么会这样?
亲切的问候,瑞尔