Skip to content

getDecimalPlaces 获取小数位数

function getDecimalPlaces(num: number): number

获取数字的小数位数,整数返回 0

参数

参数名说明类型默认值
num待检查的数字number必填

返回值

返回值说明类型
count小数位数;整数返回 0number

示例

typescript
import { getDecimalPlaces } from '@mingto/tools'

getDecimalPlaces(1.23) // 2
getDecimalPlaces(10) // 0
getDecimalPlaces(0.001) // 3