round()
本节介绍 Zoho Creator 中的 round() 函数的语法和使用。
描述
round() 函数返回四舍五入到指定数字位数之后的数字。
语法
<numeric>.round(<precision-numeric>)
返回值
返回四舍五入到指定数字位数之后的数字。
示例
num=81.256;
rounded_numt=num.round(2); // 返回 81.26
示例
将一个数向上取整/向下取整到最近的千位数。例如,若要将数字 133,768 向上取整到 134,000 或将数字 133,768 向下取整到 133,000,您可以添加以下脚本
//Round up 133,768 to 134,000
Number = 133,768;
Rounded_Number = input.Number/ 1000; //gives 133.768
Rounded_Number = Rounded_Number.round(0); //gives 134
Rounded_Number = Rounded_Number * 1000; //gives 134,000
//Round up 133,768 to 133,000
Number = 133,768;
Rounded_Number = input.Number/ 1000; //gives 133.768
Whole_Number = Rounded_Number.tolong(); //gives 133 by converting to an integer
Rounded_Number = Whole_Number * 1000; //gives 133,000