mirror of
https://github.com/penxio/penx.git
synced 2026-01-15 00:18:08 -05:00
35 lines
769 B
TypeScript
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()
|
|
}
|