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