Math.round
Math.round
功能
四舍五入。返回四舍五入后的数字。
语法
Math.round(value)
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| value | Number | 是 | 无 | 参与取整的数字。 |
返回值
| 类型 | 说明 |
|---|---|
| Int/Float | 返回四舍五入后的数字。整数结果返回 Int,非整数或非有限结果返回 Float。 |
示例
result = Math.round(1.6) // 输出:2 print result
注意事项
- 整数结果会返回 Int。
四舍五入。返回四舍五入后的数字。
Math.round(value)
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| value | Number | 是 | 无 | 参与取整的数字。 |
| 类型 | 说明 |
|---|---|
| Int/Float | 返回四舍五入后的数字。整数结果返回 Int,非整数或非有限结果返回 Float。 |
result = Math.round(1.6) // 输出:2 print result