MathX
Flexible math tool with chainable APIs.
constructor(value?: number, precision?: number, rounding?: "half-up" | "up" | "down")
value
: Initial value. Defaults to 0
.precision
: Decimal places. Defaults to 2
.rounding
: Rounding mode. Defaults to 'half-up'
.MathX
instance.set(value: number): this
value
: New value.value(): number
setPrecision(digits: number): this
digits
: Number of decimal places.setRounding(mode: "half-up" | "up" | "down"): this
mode
: Rounding mode ('half-up'
, 'up'
, 'down'
).clone(value?: number): MathX
value
: Optional new value.MathX
instance.add(num: number): this
num
: Number to add.subtract(num: number): this
num
: Number to subtract.multiply(num: number): this
num
: Number to multiply.divide(num: number): this
num
: Number to divide by.num
is 0
.abs(): this
sqrt(): this
cbrt(): this
pow(exp: number): this
exp
: Exponent.floor(): this
ceil(): this
round(): this
sign(): this
degToRad(): this
radToDeg(): this
max(...nums: number[]): this
nums
: Numbers to compare.min(...nums: number[]): this
nums
: Numbers to compare.sin(): this
cos(): this
tan(): this
asin(): this
acos(): this
atan(): this
log(): this
log10(): this
exp(): this
toExponential(fractionDigits?: number): string
fractionDigits
: Number of digits after the decimal point. If omitted, uses as many digits as necessary.