Gathering detailed insights and metrics for @fox-js/big-decimal
Gathering detailed insights and metrics for @fox-js/big-decimal
npm install @fox-js/big-decimal
Typescript
Module System
Node Version
NPM Version
Total Downloads
1,948
Last Day
1
Last Week
7
Last Month
40
Last Year
655
Minified
Minified + Gzipped
Latest Version
4.0.1-0
Package Id
@fox-js/big-decimal@4.0.1-0
Unpacked Size
32.07 kB
Size
8.86 kB
File Count
8
NPM Version
7.20.3
Node Version
16.6.1
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-65%
7
Compared to previous week
Last month
53.8%
40
Compared to previous month
Last year
21.5%
655
Compared to previous year
1
大数操作(加、减、乘、除、格式化)的工具类.
1npm i @fox-js/big-decimal -S
1yarn add @fox-js/big-decimal
直接在代码中引入模块即可,模块会自动完成初始化并生效
1import '@fox-js/big-decimal'
multiply(x, y)
1import { multiply } from '@fox-js/big-decimal' 2// 相乘 3let n = multiply(336662, 3) 4console.info(`multiply:${n}`)
divide(x, y, precision = 8)
1import { divide } from '@fox-js/big-decimal' 2// 相除(最后一位为小数点) 3n = divide(36223, 3, 2) 4console.info(`divide:${n}`)
add(x, y)
1import { divide } from '@fox-js/big-decimal' 2// 相加 3n = add(3533, 15) 4console.info(`add:${n}`)
subtract(x, y)
1import { subtract } from '@fox-js/big-decimal' 2// 相减 3n = subtract(122223, 22321312) 4console.info(`subtract:${n}`)
round(number, precision, roundingMode) 按指定的位数对数值进行四舍五入
1import { round } from '@fox-js/big-decimal' 2 3round('123.678', 2) //"123.68" 4round('123.657', 1, RoundingModes.DOWN) // "123.6" 5round('123.657', 2, RoundingModes.CEILING) // "123.66"
Round also supports the following rounding modes
floor(number) Returns the whole number nearest but not greater than the input number.
1floor(12.8) // "12" 2floor(-12.3) // "-13"
ceil(number) Returns the whole number nearest but not lesser than the input number.
1ceil(12.8) // "13" 2ceil(-12.3) // "-12"
Returns negation of a given number.
1negate('123.678') // "-123.678" 2negate('-1234') // "1234"
numCompareTo(number1, number2) 比较两个数据,Returns 1, 0 and -1 if number1 > number2, number1 == number2 and number1 < number2 respectively.
1compareTo('23.678', '67.34') // value = -1 2compareTo('23.678', '23.6780') // value = 0 3compareTo('123.678', '67.34') // value = 1
inScope(number, min, max)
1inScope('1', '1', '5') // false 2inScope('3', '1', '10') // true
scaleNumber(value, scale) 如果 scale>0 代表 multiply(value,scale) 如果 scale<0 代表 divide(value, negate(scale))
1scaleNumber('100', '5') // 500 2scaleNumber('100', '-5') // 20
numberFormat(value, decimalLength = -1, autoPadding = false, digits = 3, separator = ',')
1numberFormat('123456') // 123,456 2numberFormat('123456.978', 2) // 123,456.97 3numberFormat('123456.9', 2, true) // 123,456.90
unNumberFormat(value)
1unNumberFormat('123,456') // 123456
No vulnerabilities found.
No security vulnerabilities found.