描述
将数字四舍五入到指定精度
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| num | number | 数字 |
| precision? | number | 精度 (默认 0) |
返回值
number 四舍五入后的数字
示例
javascript
turf.round(120.4321);
//=120
turf.round(120.4321, 2);
//=120.43安装
javascript
$ npm install @turf/helpers
import { round } from "@turf/helpers";
const result = round(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.round(...);