2017-11-25 23:42:03 +00:00
|
|
|
// Type definitions for decimal.js >=7.0.0
|
|
|
|
// Project: https://github.com/MikeMcl/decimal.js
|
|
|
|
// Definitions by: Michael Mclaughlin <https://github.com/MikeMcl>
|
|
|
|
// Definitions: https://github.com/MikeMcl/decimal.js
|
|
|
|
//
|
|
|
|
// Documentation: http://mikemcl.github.io/decimal.js/
|
|
|
|
//
|
2018-03-10 22:10:08 +00:00
|
|
|
// Exports:
|
2017-11-25 23:42:03 +00:00
|
|
|
//
|
2017-12-03 17:42:48 +00:00
|
|
|
// class Decimal (default export)
|
2017-11-25 23:42:03 +00:00
|
|
|
// type Decimal.Constructor
|
2017-12-03 17:42:48 +00:00
|
|
|
// type Decimal.Instance
|
2017-11-25 23:42:03 +00:00
|
|
|
// type Decimal.Modulo
|
2017-12-03 17:42:48 +00:00
|
|
|
// type Decimal.Rounding
|
|
|
|
// type Decimal.Value
|
2017-11-25 23:42:03 +00:00
|
|
|
// interface Decimal.Config
|
|
|
|
//
|
2017-12-03 17:42:48 +00:00
|
|
|
// Example (alternative syntax commented-out):
|
2017-11-25 23:42:03 +00:00
|
|
|
//
|
2017-12-03 17:42:48 +00:00
|
|
|
// import {Decimal} from "decimal.js"
|
|
|
|
// //import Decimal from "decimal.js"
|
2017-11-25 23:42:03 +00:00
|
|
|
//
|
|
|
|
// let r: Decimal.Rounding = Decimal.ROUND_UP;
|
|
|
|
// let c: Decimal.Configuration = {precision: 4, rounding: r};
|
|
|
|
// Decimal.set(c);
|
|
|
|
// let v: Decimal.Value = '12345.6789';
|
|
|
|
// let d: Decimal = new Decimal(v);
|
2017-12-03 17:42:48 +00:00
|
|
|
// //let d: Decimal.Instance = new Decimal(v);
|
|
|
|
//
|
|
|
|
// The use of compiler option `--strictNullChecks` is recommended.
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
export default Decimal;
|
|
|
|
|
|
|
|
export namespace Decimal {
|
2018-03-10 22:00:51 +00:00
|
|
|
export type Constructor = typeof Decimal;
|
|
|
|
export type Instance = Decimal;
|
|
|
|
export type Rounding = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|
|
|
export type Modulo = Rounding | 9;
|
|
|
|
export type Value = string | number | Decimal;
|
|
|
|
|
|
|
|
// http://mikemcl.github.io/decimal.js/#constructor-properties
|
|
|
|
export interface Config {
|
|
|
|
precision?: number;
|
|
|
|
rounding?: Rounding;
|
|
|
|
toExpNeg?: number;
|
|
|
|
toExpPos?: number;
|
|
|
|
minE?: number;
|
|
|
|
maxE?: number;
|
|
|
|
crypto?: boolean;
|
|
|
|
modulo?: Modulo;
|
|
|
|
defaults?: boolean;
|
2017-11-25 23:42:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export declare class Decimal {
|
|
|
|
readonly d: number[];
|
|
|
|
readonly e: number;
|
|
|
|
readonly s: number;
|
2021-06-22 18:20:14 +00:00
|
|
|
private readonly toStringTag: string;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
constructor(n: Decimal.Value);
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
absoluteValue(): Decimal;
|
|
|
|
abs(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
ceil(): Decimal;
|
2021-06-22 11:50:27 +00:00
|
|
|
|
|
|
|
clampedTo(min: Decimal.Value, max: Decimal.Value): Decimal;
|
|
|
|
clamp(min: Decimal.Value, max: Decimal.Value): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
comparedTo(n: Decimal.Value): number;
|
|
|
|
cmp(n: Decimal.Value): number;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
cosine(): Decimal;
|
|
|
|
cos(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
cubeRoot(): Decimal;
|
|
|
|
cbrt(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
decimalPlaces(): number;
|
|
|
|
dp(): number;
|
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
dividedBy(n: Decimal.Value): Decimal;
|
|
|
|
div(n: Decimal.Value): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
dividedToIntegerBy(n: Decimal.Value): Decimal;
|
|
|
|
divToInt(n: Decimal.Value): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
equals(n: Decimal.Value): boolean;
|
|
|
|
eq(n: Decimal.Value): boolean;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
floor(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
greaterThan(n: Decimal.Value): boolean;
|
|
|
|
gt(n: Decimal.Value): boolean;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
greaterThanOrEqualTo(n: Decimal.Value): boolean;
|
|
|
|
gte(n: Decimal.Value): boolean;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
hyperbolicCosine(): Decimal;
|
|
|
|
cosh(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
hyperbolicSine(): Decimal;
|
|
|
|
sinh(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
hyperbolicTangent(): Decimal;
|
|
|
|
tanh(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
inverseCosine(): Decimal;
|
|
|
|
acos(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
inverseHyperbolicCosine(): Decimal;
|
|
|
|
acosh(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
inverseHyperbolicSine(): Decimal;
|
|
|
|
asinh(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
inverseHyperbolicTangent(): Decimal;
|
|
|
|
atanh(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
inverseSine(): Decimal;
|
|
|
|
asin(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
inverseTangent(): Decimal;
|
|
|
|
atan(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
isFinite(): boolean;
|
|
|
|
|
|
|
|
isInteger(): boolean;
|
|
|
|
isInt(): boolean;
|
|
|
|
|
|
|
|
isNaN(): boolean;
|
|
|
|
|
|
|
|
isNegative(): boolean;
|
|
|
|
isNeg(): boolean;
|
|
|
|
|
|
|
|
isPositive(): boolean;
|
|
|
|
isPos(): boolean;
|
|
|
|
|
|
|
|
isZero(): boolean;
|
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
lessThan(n: Decimal.Value): boolean;
|
|
|
|
lt(n: Decimal.Value): boolean;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
lessThanOrEqualTo(n: Decimal.Value): boolean;
|
|
|
|
lte(n: Decimal.Value): boolean;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
logarithm(n?: Decimal.Value): Decimal;
|
|
|
|
log(n?: Decimal.Value): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
minus(n: Decimal.Value): Decimal;
|
|
|
|
sub(n: Decimal.Value): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
modulo(n: Decimal.Value): Decimal;
|
|
|
|
mod(n: Decimal.Value): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
naturalExponential(): Decimal;
|
|
|
|
exp(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
naturalLogarithm(): Decimal;
|
|
|
|
ln(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
negated(): Decimal;
|
|
|
|
neg(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
plus(n: Decimal.Value): Decimal;
|
|
|
|
add(n: Decimal.Value): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
precision(includeZeros?: boolean): number;
|
|
|
|
sd(includeZeros?: boolean): number;
|
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
round(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
sine() : Decimal;
|
|
|
|
sin() : Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
squareRoot(): Decimal;
|
|
|
|
sqrt(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
tangent() : Decimal;
|
|
|
|
tan() : Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
times(n: Decimal.Value): Decimal;
|
|
|
|
mul(n: Decimal.Value) : Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
toBinary(significantDigits?: number): string;
|
2018-03-10 22:00:51 +00:00
|
|
|
toBinary(significantDigits: number, rounding: Decimal.Rounding): string;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
toDecimalPlaces(decimalPlaces?: number): Decimal;
|
2018-03-10 22:00:51 +00:00
|
|
|
toDecimalPlaces(decimalPlaces: number, rounding: Decimal.Rounding): Decimal;
|
2017-12-15 10:37:01 +00:00
|
|
|
toDP(decimalPlaces?: number): Decimal;
|
2018-03-10 22:00:51 +00:00
|
|
|
toDP(decimalPlaces: number, rounding: Decimal.Rounding): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
toExponential(decimalPlaces?: number): string;
|
2018-03-10 22:00:51 +00:00
|
|
|
toExponential(decimalPlaces: number, rounding: Decimal.Rounding): string;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
toFixed(decimalPlaces?: number): string;
|
2018-03-10 22:00:51 +00:00
|
|
|
toFixed(decimalPlaces: number, rounding: Decimal.Rounding): string;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
toFraction(max_denominator?: Decimal.Value): Decimal[];
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
toHexadecimal(significantDigits?: number): string;
|
2018-03-10 22:00:51 +00:00
|
|
|
toHexadecimal(significantDigits: number, rounding: Decimal.Rounding): string;
|
2017-12-15 10:37:01 +00:00
|
|
|
toHex(significantDigits?: number): string;
|
2018-03-10 22:00:51 +00:00
|
|
|
toHex(significantDigits: number, rounding?: Decimal.Rounding): string;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
toJSON(): string;
|
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
toNearest(n: Decimal.Value, rounding?: Decimal.Rounding): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
toNumber(): number;
|
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
toOctal(significantDigits?: number): string;
|
2018-03-10 22:00:51 +00:00
|
|
|
toOctal(significantDigits: number, rounding: Decimal.Rounding): string;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
toPower(n: Decimal.Value): Decimal;
|
|
|
|
pow(n: Decimal.Value): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
toPrecision(significantDigits?: number): string;
|
2018-03-10 22:00:51 +00:00
|
|
|
toPrecision(significantDigits: number, rounding: Decimal.Rounding): string;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
toSignificantDigits(significantDigits?: number): Decimal;
|
2018-03-10 22:00:51 +00:00
|
|
|
toSignificantDigits(significantDigits: number, rounding: Decimal.Rounding): Decimal;
|
2017-12-15 10:37:01 +00:00
|
|
|
toSD(significantDigits?: number): Decimal;
|
2018-03-10 22:00:51 +00:00
|
|
|
toSD(significantDigits: number, rounding: Decimal.Rounding): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
toString(): string;
|
|
|
|
|
2017-12-15 10:37:01 +00:00
|
|
|
truncated(): Decimal;
|
|
|
|
trunc(): Decimal;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
valueOf(): string;
|
|
|
|
|
2018-03-10 22:00:51 +00:00
|
|
|
static abs(n: Decimal.Value): Decimal;
|
|
|
|
static acos(n: Decimal.Value): Decimal;
|
|
|
|
static acosh(n: Decimal.Value): Decimal;
|
|
|
|
static add(x: Decimal.Value, y: Decimal.Value): Decimal;
|
|
|
|
static asin(n: Decimal.Value): Decimal;
|
|
|
|
static asinh(n: Decimal.Value): Decimal;
|
|
|
|
static atan(n: Decimal.Value): Decimal;
|
|
|
|
static atanh(n: Decimal.Value): Decimal;
|
|
|
|
static atan2(y: Decimal.Value, x: Decimal.Value): Decimal;
|
|
|
|
static cbrt(n: Decimal.Value): Decimal;
|
|
|
|
static ceil(n: Decimal.Value): Decimal;
|
2021-06-22 11:50:27 +00:00
|
|
|
static clamp(n: Decimal.Value, min: Decimal.Value, max: Decimal.Value): Decimal;
|
2018-03-10 22:00:51 +00:00
|
|
|
static clone(object?: Decimal.Config): Decimal.Constructor;
|
|
|
|
static config(object: Decimal.Config): Decimal.Constructor;
|
|
|
|
static cos(n: Decimal.Value): Decimal;
|
|
|
|
static cosh(n: Decimal.Value): Decimal;
|
|
|
|
static div(x: Decimal.Value, y: Decimal.Value): Decimal;
|
|
|
|
static exp(n: Decimal.Value): Decimal;
|
|
|
|
static floor(n: Decimal.Value): Decimal;
|
|
|
|
static hypot(...n: Decimal.Value[]): Decimal;
|
2022-04-08 13:33:02 +00:00
|
|
|
static isDecimal(object: any): object is Decimal;
|
2018-03-10 22:00:51 +00:00
|
|
|
static ln(n: Decimal.Value): Decimal;
|
|
|
|
static log(n: Decimal.Value, base?: Decimal.Value): Decimal;
|
|
|
|
static log2(n: Decimal.Value): Decimal;
|
|
|
|
static log10(n: Decimal.Value): Decimal;
|
|
|
|
static max(...n: Decimal.Value[]): Decimal;
|
|
|
|
static min(...n: Decimal.Value[]): Decimal;
|
|
|
|
static mod(x: Decimal.Value, y: Decimal.Value): Decimal;
|
|
|
|
static mul(x: Decimal.Value, y: Decimal.Value): Decimal;
|
|
|
|
static noConflict(): Decimal.Constructor; // Browser only
|
|
|
|
static pow(base: Decimal.Value, exponent: Decimal.Value): Decimal;
|
2017-12-15 10:37:01 +00:00
|
|
|
static random(significantDigits?: number): Decimal;
|
2018-03-10 22:00:51 +00:00
|
|
|
static round(n: Decimal.Value): Decimal;
|
|
|
|
static set(object: Decimal.Config): Decimal.Constructor;
|
|
|
|
static sign(n: Decimal.Value): Decimal;
|
|
|
|
static sin(n: Decimal.Value): Decimal;
|
|
|
|
static sinh(n: Decimal.Value): Decimal;
|
|
|
|
static sqrt(n: Decimal.Value): Decimal;
|
|
|
|
static sub(x: Decimal.Value, y: Decimal.Value): Decimal;
|
2021-06-22 11:50:27 +00:00
|
|
|
static sum(...n: Decimal.Value[]): Decimal;
|
2018-03-10 22:00:51 +00:00
|
|
|
static tan(n: Decimal.Value): Decimal;
|
|
|
|
static tanh(n: Decimal.Value): Decimal;
|
|
|
|
static trunc(n: Decimal.Value): Decimal;
|
|
|
|
|
|
|
|
static readonly default?: Decimal.Constructor;
|
|
|
|
static readonly Decimal?: Decimal.Constructor;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
static readonly precision: number;
|
2018-03-10 22:00:51 +00:00
|
|
|
static readonly rounding: Decimal.Rounding;
|
2017-11-25 23:42:03 +00:00
|
|
|
static readonly toExpNeg: number;
|
|
|
|
static readonly toExpPos: number;
|
|
|
|
static readonly minE: number;
|
|
|
|
static readonly maxE: number;
|
|
|
|
static readonly crypto: boolean;
|
2018-03-10 22:00:51 +00:00
|
|
|
static readonly modulo: Decimal.Modulo;
|
2017-11-25 23:42:03 +00:00
|
|
|
|
|
|
|
static readonly ROUND_UP: 0;
|
|
|
|
static readonly ROUND_DOWN: 1;
|
|
|
|
static readonly ROUND_CEIL: 2;
|
|
|
|
static readonly ROUND_FLOOR: 3;
|
|
|
|
static readonly ROUND_HALF_UP: 4;
|
|
|
|
static readonly ROUND_HALF_DOWN: 5;
|
|
|
|
static readonly ROUND_HALF_EVEN: 6;
|
|
|
|
static readonly ROUND_HALF_CEIL: 7;
|
|
|
|
static readonly ROUND_HALF_FLOOR: 8;
|
|
|
|
static readonly EUCLID: 9;
|
|
|
|
}
|