[英]App script spreadsheets float calculation, can google app script do float point number calc?
Google App脚本可以在Google App脚本中使用外部库来进行浮点数计算吗,例如bigdecimal?
当我做
var i = 1.15 - 1.12 console.log(i);
那么i = 0.029999999999999805
但是,如果您只想将其舍入到小数点后两位(或更多),则不必诉诸外部库,请使用Math.round :
function floatNumber(){
var myInt = 1.15 - 1.12 ;
myInt = Math.round(myInt * 100) / 100;
Logger.log(myInt);
//output 0.03
//if you want 3 decimal places use /1000, and so on.
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.