Skip to content

Function: getDecimalPlaces()

ts
function getDecimalPlaces(num): number;

Get the number of decimal places in a number. 获取数字的小数位数。

Parameters

ParameterTypeDescription
numnumberA number to find the decimal places of / 要查找小数位数的数字

Returns

number

The number of decimal places / 小数位数

Example

ts
getDecimalPlaces(1.005) // => 3
getDecimalPlaces(5) // => 0

Since

1.0.0

Released under the MIT License.