Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@fox-js/big-decimal
Advanced tools
大数操作(加、减、乘、除、格式化)的工具类.
npm i @fox-js/big-decimal -S
yarn add @fox-js/big-decimal
直接在代码中引入模块即可,模块会自动完成初始化并生效
import '@fox-js/big-decimal'
multiply(x, y)
import { multiply } from '@fox-js/big-decimal'
// 相乘
let n = multiply(336662, 3)
console.info(`multiply:${n}`)
divide(x, y, precision = 8)
import { divide } from '@fox-js/big-decimal'
// 相除(最后一位为小数点)
n = divide(36223, 3, 2)
console.info(`divide:${n}`)
add(x, y)
import { divide } from '@fox-js/big-decimal'
// 相加
n = add(3533, 15)
console.info(`add:${n}`)
subtract(x, y)
import { subtract } from '@fox-js/big-decimal'
// 相减
n = subtract(122223, 22321312)
console.info(`subtract:${n}`)
round(number, precision, roundingMode) 按指定的位数对数值进行四舍五入
import { round } from '@fox-js/big-decimal'
round('123.678', 2) //"123.68"
round('123.657', 1, RoundingModes.DOWN) // "123.6"
round('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.
floor(12.8) // "12"
floor(-12.3) // "-13"
ceil(number) Returns the whole number nearest but not lesser than the input number.
ceil(12.8) // "13"
ceil(-12.3) // "-12"
Returns negation of a given number.
negate('123.678') // "-123.678"
negate('-1234') // "1234"
numCompareTo(number1, number2) 比较两个数据,Returns 1, 0 and -1 if number1 > number2, number1 == number2 and number1 < number2 respectively.
compareTo('23.678', '67.34') // value = -1
compareTo('23.678', '23.6780') // value = 0
compareTo('123.678', '67.34') // value = 1
inScope(number, min, max)
inScope('1', '1', '5') // false
inScope('3', '1', '10') // true
scaleNumber(value, scale) 如果 scale>0 代表 multiply(value,scale) 如果 scale<0 代表 divide(value, negate(scale))
scaleNumber('100', '5') // 500
scaleNumber('100', '-5') // 20
numberFormat(value, decimalLength = -1, autoPadding = false, digits = 3, separator = ',')
numberFormat('123456') // 123,456
numberFormat('123456.978', 2) // 123,456.97
numberFormat('123456.9', 2, true) // 123,456.90
unNumberFormat(value)
unNumberFormat('123,456') // 123456
FAQs
Fox Big Decimal utils
We found that @fox-js/big-decimal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.