Skip to content

描述 ​

将数字四舍五入到指定精度

参数 ​

名称类型描述
numnumber数字
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(...);