0
變量添加號碼如果加入,我拉過一個CSV數字,這就是我得到的日誌文件:在谷歌Apps腳本會奇怪
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
爲什麼會發生這種情況?
親切的問候, 瑞爾