Files
penx/lib/math/math.ts
2024-08-05 10:06:02 +08:00

35 lines
769 B
TypeScript

import Big from 'big.js'
export function plus(...args: Big.BigSource[]) {
const [value, ...rest] = args
let big = new Big(value)
for (const item of rest) {
big = big.plus(item)
}
return big.toNumber()
}
export function minus(value: Big.BigSource, ...args: Big.BigSource[]) {
let big = new Big(value)
for (const item of args) {
big = big.minus(item)
}
return big.toNumber()
}
export function times(value: Big.BigSource, ...args: Big.BigSource[]) {
let big = new Big(value)
for (const item of args) {
big = big.times(item)
}
return big.toNumber()
}
export function div(value: Big.BigSource, ...args: Big.BigSource[]) {
let big = new Big(value)
for (const item of args) {
big = big.div(item)
}
return big.toNumber()
}