HarmonyOS 鸿蒙Next 云函数里是否有类似Excel truncate方法只取小数点后2位且不求四舍五入的?
HarmonyOS 鸿蒙Next 云函数里是否有类似Excel truncate方法只取小数点后2位且不求四舍五入的?
请问云函数里有类似于Excel的truncate方法只取小数点后2位数,但不需要求四舍五入的?
let myHandler = function(event, context, callback, logger) {
let totalAmount = event.totalAmount;
try {
//云函数里怎么只截取小数点后两位数,小数点第3位数舍弃不需要四舍五入的?
let totalWeeklyAmount = totalAmount/52;
logger.info("request: " + JSON.stringify(event.request));
let res = new context.HTTPResponse(context.env, {
"res-type": "context.env",
"faas-content-type": "json",
}, "application/json", "200");
res.body = {"totalWeeklyAmount": totalWeeklyAmount};
callback(res);
} catch (error) {
logger.error("--------Error-------");
logger.error("error: " + error);
callback(error);
}
};
module.exports.myHandler = myHandler;
更多关于HarmonyOS 鸿蒙Next 云函数里是否有类似Excel truncate方法只取小数点后2位且不求四舍五入的?的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
1 回复