| 1 | // Type definitions for decimal.js >=7.0.0
|
|---|
| 2 | // Project: https://github.com/MikeMcl/decimal.js
|
|---|
| 3 | // Definitions by: Michael Mclaughlin <https://github.com/MikeMcl>
|
|---|
| 4 | // Definitions: https://github.com/MikeMcl/decimal.js
|
|---|
| 5 | //
|
|---|
| 6 | // Documentation: http://mikemcl.github.io/decimal.js/
|
|---|
| 7 | //
|
|---|
| 8 | // Exports:
|
|---|
| 9 | //
|
|---|
| 10 | // class Decimal (default export)
|
|---|
| 11 | // type Decimal.Constructor
|
|---|
| 12 | // type Decimal.Instance
|
|---|
| 13 | // type Decimal.Modulo
|
|---|
| 14 | // type Decimal.Rounding
|
|---|
| 15 | // type Decimal.Value
|
|---|
| 16 | // interface Decimal.Config
|
|---|
| 17 | //
|
|---|
| 18 | // Example (alternative syntax commented-out):
|
|---|
| 19 | //
|
|---|
| 20 | // import {Decimal} from "decimal.js"
|
|---|
| 21 | // //import Decimal from "decimal.js"
|
|---|
| 22 | //
|
|---|
| 23 | // let r: Decimal.Rounding = Decimal.ROUND_UP;
|
|---|
| 24 | // let c: Decimal.Configuration = {precision: 4, rounding: r};
|
|---|
| 25 | // Decimal.set(c);
|
|---|
| 26 | // let v: Decimal.Value = '12345.6789';
|
|---|
| 27 | // let d: Decimal = new Decimal(v);
|
|---|
| 28 | // //let d: Decimal.Instance = new Decimal(v);
|
|---|
| 29 | //
|
|---|
| 30 | // The use of compiler option `--strictNullChecks` is recommended.
|
|---|
| 31 |
|
|---|
| 32 | export default Decimal;
|
|---|
| 33 |
|
|---|
| 34 | export namespace Decimal {
|
|---|
| 35 | export type Constructor = typeof Decimal;
|
|---|
| 36 | export type Instance = Decimal;
|
|---|
| 37 | export type Rounding = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
|
|---|
| 38 | export type Modulo = Rounding | 9;
|
|---|
| 39 | export type Value = string | number | bigint | Decimal;
|
|---|
| 40 |
|
|---|
| 41 | // http://mikemcl.github.io/decimal.js/#constructor-properties
|
|---|
| 42 | export interface Config {
|
|---|
| 43 | precision?: number;
|
|---|
| 44 | rounding?: Rounding;
|
|---|
| 45 | toExpNeg?: number;
|
|---|
| 46 | toExpPos?: number;
|
|---|
| 47 | minE?: number;
|
|---|
| 48 | maxE?: number;
|
|---|
| 49 | crypto?: boolean;
|
|---|
| 50 | modulo?: Modulo;
|
|---|
| 51 | defaults?: boolean;
|
|---|
| 52 | }
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | export declare class Decimal {
|
|---|
| 56 | readonly d: number[];
|
|---|
| 57 | readonly e: number;
|
|---|
| 58 | readonly s: number;
|
|---|
| 59 |
|
|---|
| 60 | constructor(n: Decimal.Value);
|
|---|
| 61 |
|
|---|
| 62 | absoluteValue(): Decimal;
|
|---|
| 63 | abs(): Decimal;
|
|---|
| 64 |
|
|---|
| 65 | ceil(): Decimal;
|
|---|
| 66 |
|
|---|
| 67 | clampedTo(min: Decimal.Value, max: Decimal.Value): Decimal;
|
|---|
| 68 | clamp(min: Decimal.Value, max: Decimal.Value): Decimal;
|
|---|
| 69 |
|
|---|
| 70 | comparedTo(n: Decimal.Value): number;
|
|---|
| 71 | cmp(n: Decimal.Value): number;
|
|---|
| 72 |
|
|---|
| 73 | cosine(): Decimal;
|
|---|
| 74 | cos(): Decimal;
|
|---|
| 75 |
|
|---|
| 76 | cubeRoot(): Decimal;
|
|---|
| 77 | cbrt(): Decimal;
|
|---|
| 78 |
|
|---|
| 79 | decimalPlaces(): number;
|
|---|
| 80 | dp(): number;
|
|---|
| 81 |
|
|---|
| 82 | dividedBy(n: Decimal.Value): Decimal;
|
|---|
| 83 | div(n: Decimal.Value): Decimal;
|
|---|
| 84 |
|
|---|
| 85 | dividedToIntegerBy(n: Decimal.Value): Decimal;
|
|---|
| 86 | divToInt(n: Decimal.Value): Decimal;
|
|---|
| 87 |
|
|---|
| 88 | equals(n: Decimal.Value): boolean;
|
|---|
| 89 | eq(n: Decimal.Value): boolean;
|
|---|
| 90 |
|
|---|
| 91 | floor(): Decimal;
|
|---|
| 92 |
|
|---|
| 93 | greaterThan(n: Decimal.Value): boolean;
|
|---|
| 94 | gt(n: Decimal.Value): boolean;
|
|---|
| 95 |
|
|---|
| 96 | greaterThanOrEqualTo(n: Decimal.Value): boolean;
|
|---|
| 97 | gte(n: Decimal.Value): boolean;
|
|---|
| 98 |
|
|---|
| 99 | hyperbolicCosine(): Decimal;
|
|---|
| 100 | cosh(): Decimal;
|
|---|
| 101 |
|
|---|
| 102 | hyperbolicSine(): Decimal;
|
|---|
| 103 | sinh(): Decimal;
|
|---|
| 104 |
|
|---|
| 105 | hyperbolicTangent(): Decimal;
|
|---|
| 106 | tanh(): Decimal;
|
|---|
| 107 |
|
|---|
| 108 | inverseCosine(): Decimal;
|
|---|
| 109 | acos(): Decimal;
|
|---|
| 110 |
|
|---|
| 111 | inverseHyperbolicCosine(): Decimal;
|
|---|
| 112 | acosh(): Decimal;
|
|---|
| 113 |
|
|---|
| 114 | inverseHyperbolicSine(): Decimal;
|
|---|
| 115 | asinh(): Decimal;
|
|---|
| 116 |
|
|---|
| 117 | inverseHyperbolicTangent(): Decimal;
|
|---|
| 118 | atanh(): Decimal;
|
|---|
| 119 |
|
|---|
| 120 | inverseSine(): Decimal;
|
|---|
| 121 | asin(): Decimal;
|
|---|
| 122 |
|
|---|
| 123 | inverseTangent(): Decimal;
|
|---|
| 124 | atan(): Decimal;
|
|---|
| 125 |
|
|---|
| 126 | isFinite(): boolean;
|
|---|
| 127 |
|
|---|
| 128 | isInteger(): boolean;
|
|---|
| 129 | isInt(): boolean;
|
|---|
| 130 |
|
|---|
| 131 | isNaN(): boolean;
|
|---|
| 132 |
|
|---|
| 133 | isNegative(): boolean;
|
|---|
| 134 | isNeg(): boolean;
|
|---|
| 135 |
|
|---|
| 136 | isPositive(): boolean;
|
|---|
| 137 | isPos(): boolean;
|
|---|
| 138 |
|
|---|
| 139 | isZero(): boolean;
|
|---|
| 140 |
|
|---|
| 141 | lessThan(n: Decimal.Value): boolean;
|
|---|
| 142 | lt(n: Decimal.Value): boolean;
|
|---|
| 143 |
|
|---|
| 144 | lessThanOrEqualTo(n: Decimal.Value): boolean;
|
|---|
| 145 | lte(n: Decimal.Value): boolean;
|
|---|
| 146 |
|
|---|
| 147 | logarithm(n?: Decimal.Value): Decimal;
|
|---|
| 148 | log(n?: Decimal.Value): Decimal;
|
|---|
| 149 |
|
|---|
| 150 | minus(n: Decimal.Value): Decimal;
|
|---|
| 151 | sub(n: Decimal.Value): Decimal;
|
|---|
| 152 |
|
|---|
| 153 | modulo(n: Decimal.Value): Decimal;
|
|---|
| 154 | mod(n: Decimal.Value): Decimal;
|
|---|
| 155 |
|
|---|
| 156 | naturalExponential(): Decimal;
|
|---|
| 157 | exp(): Decimal;
|
|---|
| 158 |
|
|---|
| 159 | naturalLogarithm(): Decimal;
|
|---|
| 160 | ln(): Decimal;
|
|---|
| 161 |
|
|---|
| 162 | negated(): Decimal;
|
|---|
| 163 | neg(): Decimal;
|
|---|
| 164 |
|
|---|
| 165 | plus(n: Decimal.Value): Decimal;
|
|---|
| 166 | add(n: Decimal.Value): Decimal;
|
|---|
| 167 |
|
|---|
| 168 | precision(includeZeros?: boolean): number;
|
|---|
| 169 | sd(includeZeros?: boolean): number;
|
|---|
| 170 |
|
|---|
| 171 | round(): Decimal;
|
|---|
| 172 |
|
|---|
| 173 | sine() : Decimal;
|
|---|
| 174 | sin() : Decimal;
|
|---|
| 175 |
|
|---|
| 176 | squareRoot(): Decimal;
|
|---|
| 177 | sqrt(): Decimal;
|
|---|
| 178 |
|
|---|
| 179 | tangent() : Decimal;
|
|---|
| 180 | tan() : Decimal;
|
|---|
| 181 |
|
|---|
| 182 | times(n: Decimal.Value): Decimal;
|
|---|
| 183 | mul(n: Decimal.Value) : Decimal;
|
|---|
| 184 |
|
|---|
| 185 | toBinary(significantDigits?: number): string;
|
|---|
| 186 | toBinary(significantDigits: number, rounding: Decimal.Rounding): string;
|
|---|
| 187 |
|
|---|
| 188 | toDecimalPlaces(decimalPlaces?: number): Decimal;
|
|---|
| 189 | toDecimalPlaces(decimalPlaces: number, rounding: Decimal.Rounding): Decimal;
|
|---|
| 190 | toDP(decimalPlaces?: number): Decimal;
|
|---|
| 191 | toDP(decimalPlaces: number, rounding: Decimal.Rounding): Decimal;
|
|---|
| 192 |
|
|---|
| 193 | toExponential(decimalPlaces?: number): string;
|
|---|
| 194 | toExponential(decimalPlaces: number, rounding: Decimal.Rounding): string;
|
|---|
| 195 |
|
|---|
| 196 | toFixed(decimalPlaces?: number): string;
|
|---|
| 197 | toFixed(decimalPlaces: number, rounding: Decimal.Rounding): string;
|
|---|
| 198 |
|
|---|
| 199 | toFraction(max_denominator?: Decimal.Value): Decimal[];
|
|---|
| 200 |
|
|---|
| 201 | toHexadecimal(significantDigits?: number): string;
|
|---|
| 202 | toHexadecimal(significantDigits: number, rounding: Decimal.Rounding): string;
|
|---|
| 203 | toHex(significantDigits?: number): string;
|
|---|
| 204 | toHex(significantDigits: number, rounding?: Decimal.Rounding): string;
|
|---|
| 205 |
|
|---|
| 206 | toJSON(): string;
|
|---|
| 207 |
|
|---|
| 208 | toNearest(n: Decimal.Value, rounding?: Decimal.Rounding): Decimal;
|
|---|
| 209 |
|
|---|
| 210 | toNumber(): number;
|
|---|
| 211 |
|
|---|
| 212 | toOctal(significantDigits?: number): string;
|
|---|
| 213 | toOctal(significantDigits: number, rounding: Decimal.Rounding): string;
|
|---|
| 214 |
|
|---|
| 215 | toPower(n: Decimal.Value): Decimal;
|
|---|
| 216 | pow(n: Decimal.Value): Decimal;
|
|---|
| 217 |
|
|---|
| 218 | toPrecision(significantDigits?: number): string;
|
|---|
| 219 | toPrecision(significantDigits: number, rounding: Decimal.Rounding): string;
|
|---|
| 220 |
|
|---|
| 221 | toSignificantDigits(significantDigits?: number): Decimal;
|
|---|
| 222 | toSignificantDigits(significantDigits: number, rounding: Decimal.Rounding): Decimal;
|
|---|
| 223 | toSD(significantDigits?: number): Decimal;
|
|---|
| 224 | toSD(significantDigits: number, rounding: Decimal.Rounding): Decimal;
|
|---|
| 225 |
|
|---|
| 226 | toString(): string;
|
|---|
| 227 |
|
|---|
| 228 | truncated(): Decimal;
|
|---|
| 229 | trunc(): Decimal;
|
|---|
| 230 |
|
|---|
| 231 | valueOf(): string;
|
|---|
| 232 |
|
|---|
| 233 | static abs(n: Decimal.Value): Decimal;
|
|---|
| 234 | static acos(n: Decimal.Value): Decimal;
|
|---|
| 235 | static acosh(n: Decimal.Value): Decimal;
|
|---|
| 236 | static add(x: Decimal.Value, y: Decimal.Value): Decimal;
|
|---|
| 237 | static asin(n: Decimal.Value): Decimal;
|
|---|
| 238 | static asinh(n: Decimal.Value): Decimal;
|
|---|
| 239 | static atan(n: Decimal.Value): Decimal;
|
|---|
| 240 | static atanh(n: Decimal.Value): Decimal;
|
|---|
| 241 | static atan2(y: Decimal.Value, x: Decimal.Value): Decimal;
|
|---|
| 242 | static cbrt(n: Decimal.Value): Decimal;
|
|---|
| 243 | static ceil(n: Decimal.Value): Decimal;
|
|---|
| 244 | static clamp(n: Decimal.Value, min: Decimal.Value, max: Decimal.Value): Decimal;
|
|---|
| 245 | static clone(object?: Decimal.Config): Decimal.Constructor;
|
|---|
| 246 | static config(object: Decimal.Config): Decimal.Constructor;
|
|---|
| 247 | static cos(n: Decimal.Value): Decimal;
|
|---|
| 248 | static cosh(n: Decimal.Value): Decimal;
|
|---|
| 249 | static div(x: Decimal.Value, y: Decimal.Value): Decimal;
|
|---|
| 250 | static exp(n: Decimal.Value): Decimal;
|
|---|
| 251 | static floor(n: Decimal.Value): Decimal;
|
|---|
| 252 | static hypot(...n: Decimal.Value[]): Decimal;
|
|---|
| 253 | static isDecimal(object: any): object is Decimal;
|
|---|
| 254 | static ln(n: Decimal.Value): Decimal;
|
|---|
| 255 | static log(n: Decimal.Value, base?: Decimal.Value): Decimal;
|
|---|
| 256 | static log2(n: Decimal.Value): Decimal;
|
|---|
| 257 | static log10(n: Decimal.Value): Decimal;
|
|---|
| 258 | static max(...n: Decimal.Value[]): Decimal;
|
|---|
| 259 | static min(...n: Decimal.Value[]): Decimal;
|
|---|
| 260 | static mod(x: Decimal.Value, y: Decimal.Value): Decimal;
|
|---|
| 261 | static mul(x: Decimal.Value, y: Decimal.Value): Decimal;
|
|---|
| 262 | static noConflict(): Decimal.Constructor; // Browser only
|
|---|
| 263 | static pow(base: Decimal.Value, exponent: Decimal.Value): Decimal;
|
|---|
| 264 | static random(significantDigits?: number): Decimal;
|
|---|
| 265 | static round(n: Decimal.Value): Decimal;
|
|---|
| 266 | static set(object: Decimal.Config): Decimal.Constructor;
|
|---|
| 267 | static sign(n: Decimal.Value): number;
|
|---|
| 268 | static sin(n: Decimal.Value): Decimal;
|
|---|
| 269 | static sinh(n: Decimal.Value): Decimal;
|
|---|
| 270 | static sqrt(n: Decimal.Value): Decimal;
|
|---|
| 271 | static sub(x: Decimal.Value, y: Decimal.Value): Decimal;
|
|---|
| 272 | static sum(...n: Decimal.Value[]): Decimal;
|
|---|
| 273 | static tan(n: Decimal.Value): Decimal;
|
|---|
| 274 | static tanh(n: Decimal.Value): Decimal;
|
|---|
| 275 | static trunc(n: Decimal.Value): Decimal;
|
|---|
| 276 |
|
|---|
| 277 | static readonly default?: Decimal.Constructor;
|
|---|
| 278 | static readonly Decimal?: Decimal.Constructor;
|
|---|
| 279 |
|
|---|
| 280 | static readonly precision: number;
|
|---|
| 281 | static readonly rounding: Decimal.Rounding;
|
|---|
| 282 | static readonly toExpNeg: number;
|
|---|
| 283 | static readonly toExpPos: number;
|
|---|
| 284 | static readonly minE: number;
|
|---|
| 285 | static readonly maxE: number;
|
|---|
| 286 | static readonly crypto: boolean;
|
|---|
| 287 | static readonly modulo: Decimal.Modulo;
|
|---|
| 288 |
|
|---|
| 289 | static readonly ROUND_UP: 0;
|
|---|
| 290 | static readonly ROUND_DOWN: 1;
|
|---|
| 291 | static readonly ROUND_CEIL: 2;
|
|---|
| 292 | static readonly ROUND_FLOOR: 3;
|
|---|
| 293 | static readonly ROUND_HALF_UP: 4;
|
|---|
| 294 | static readonly ROUND_HALF_DOWN: 5;
|
|---|
| 295 | static readonly ROUND_HALF_EVEN: 6;
|
|---|
| 296 | static readonly ROUND_HALF_CEIL: 7;
|
|---|
| 297 | static readonly ROUND_HALF_FLOOR: 8;
|
|---|
| 298 | static readonly EUCLID: 9;
|
|---|
| 299 | }
|
|---|
| 300 |
|
|---|
| 301 | export declare function Decimal(n: Decimal.Value): Decimal;
|
|---|