source: node_modules/decimal.js-light/decimal.d.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 16.9 KB
Line 
1export default Decimal;
2
3export declare class Decimal {
4 /**
5 * The Decimal constructor and exported function.
6 * Return a new Decimal instance.
7 *
8 * @param value {number|string|Decimal} A numeric value.
9 *
10 */
11 constructor(value: Numeric)
12
13 /**
14 * Return a new Decimal whose value is the absolute value of this Decimal.
15 */
16 absoluteValue(): Decimal;
17
18 /**
19 * Return a new Decimal whose value is the absolute value of this Decimal.
20 */
21 abs(): Decimal;
22
23 /**
24 * Return
25 * 1 if the value of this Decimal is greater than the value of `y`,
26 * -1 if the value of this Decimal is less than the value of `y`,
27 * 0 if they have the same value
28 */
29 comparedTo(y: Numeric): 1|0|-1;
30
31 /**
32 * Return
33 * 1 if the value of this Decimal is greater than the value of `y`,
34 * -1 if the value of this Decimal is less than the value of `y`,
35 * 0 if they have the same value
36 */
37 cmp(y: Numeric): 1|0|-1;
38
39 /**
40 * Return the number of decimal places of the value of this Decimal.
41 */
42 decimalPlaces(): number;
43
44 /**
45 * Return the number of decimal places of the value of this Decimal.
46 */
47 dp(): number;
48
49 /**
50 * Return a new Decimal whose value is the value of this Decimal divided by `y`, truncated to
51 * `precision` significant digits.
52 *
53 */
54 dividedBy(y: Numeric): Decimal;
55
56 /**
57 * Return a new Decimal whose value is the value of this Decimal divided by `y`, truncated to
58 * `precision` significant digits.
59 *
60 */
61 div(y: Numeric): Decimal;
62
63 /**
64 * Return a new Decimal whose value is the integer part of dividing the value of this Decimal
65 * by the value of `y`, truncated to `precision` significant digits.
66 *
67 */
68 dividedToIntegerBy(y: Numeric): Decimal;
69
70 /**
71 * Return a new Decimal whose value is the integer part of dividing the value of this Decimal
72 * by the value of `y`, truncated to `precision` significant digits.
73 *
74 */
75 idiv(y: Numeric): Decimal;
76
77 /**
78 * Return true if the value of this Decimal is equal to the value of `y`, otherwise return false.
79 */
80 equals(y: Numeric): boolean;
81
82 /**
83 * Return true if the value of this Decimal is equal to the value of `y`, otherwise return false.
84 */
85 eq(y: Numeric): boolean;
86
87 /**
88 * Return the (base 10) exponent value of this Decimal (this.e is the base 10000000 exponent).
89 */
90 exponent(): number;
91
92 /**
93 * Return true if the value of this Decimal is greater than the value of `y`, otherwise return
94 * false.
95 */
96 greaterThan(y: Numeric): boolean;
97
98 /**
99 * Return true if the value of this Decimal is greater than the value of `y`, otherwise return
100 * false.
101 */
102 gt(y: Numeric): boolean;
103
104 /**
105 * Return true if the value of this Decimal is greater than or equal to the value of `y`,
106 * otherwise return false.
107 *
108 */
109 greaterThanOrEqualTo(y: Numeric): boolean;
110
111 /**
112 * Return true if the value of this Decimal is greater than or equal to the value of `y`,
113 * otherwise return false.
114 *
115 */
116 gte(y: Numeric): boolean;
117
118 /**
119 * Return true if the value of this Decimal is an integer, otherwise return false.
120 *
121 */
122 isInteger(): boolean;
123
124 /**
125 * Return true if the value of this Decimal is an integer, otherwise return false.
126 *
127 */
128 isint(): boolean;
129
130 /**
131 * Return true if the value of this Decimal is negative, otherwise return false.
132 *
133 */
134 isNegative(): boolean;
135
136 /**
137 * Return true if the value of this Decimal is negative, otherwise return false.
138 *
139 */
140 isneg(): boolean;
141
142 /**
143 * Return true if the value of this Decimal is positive, otherwise return false.
144 *
145 */
146 isPositive(): boolean;
147
148 /**
149 * Return true if the value of this Decimal is positive, otherwise return false.
150 *
151 */
152 ispos(): boolean;
153
154 /**
155 * Return true if the value of this Decimal is 0, otherwise return false.
156 *
157 */
158 isZero(): boolean;
159
160 /**
161 * Return true if the value of this Decimal is less than `y`, otherwise return false.
162 *
163 */
164 lessThan(y: Numeric): boolean;
165
166 /**
167 * Return true if the value of this Decimal is less than `y`, otherwise return false.
168 *
169 */
170 lt(y: Numeric): boolean;
171
172 /**
173 * Return true if the value of this Decimal is less than or equal to `y`, otherwise return false.
174 *
175 */
176 lessThanOrEqualTo(y: Numeric): boolean;
177
178 /**
179 * Return true if the value of this Decimal is less than or equal to `y`, otherwise return false.
180 *
181 */
182 lte(y: Numeric): boolean;
183
184 /**
185 * Return the logarithm of the value of this Decimal to the specified base, truncated to
186 * `precision` significant digits.
187 *
188 * If no base is specified, return log[10](x).
189 *
190 * log[base](x) = ln(x) / ln(base)
191 *
192 * The maximum error of the result is 1 ulp (unit in the last place).
193 *
194 */
195 logarithm(base?: Numeric): Decimal;
196
197 /**
198 * Return the logarithm of the value of this Decimal to the specified base, truncated to
199 * `precision` significant digits.
200 *
201 * If no base is specified, return log[10](x).
202 *
203 * log[base](x) = ln(x) / ln(base)
204 *
205 * The maximum error of the result is 1 ulp (unit in the last place).
206 *
207 */
208 log(base?: Numeric): Decimal;
209
210 /**
211 * Return a new Decimal whose value is the value of this Decimal minus `y`, truncated to
212 * `precision` significant digits.
213 *
214 */
215 minus(y: Numeric): Decimal;
216
217 /**
218 * Return a new Decimal whose value is the value of this Decimal minus `y`, truncated to
219 * `precision` significant digits.
220 *
221 */
222 sub(y: Numeric): Decimal;
223
224 /**
225 * Return a new Decimal whose value is the value of this Decimal modulo `y`, truncated to
226 * `precision` significant digits.
227 *
228 */
229 modulo(y: Numeric): Decimal;
230
231 /**
232 * Return a new Decimal whose value is the value of this Decimal modulo `y`, truncated to
233 * `precision` significant digits.
234 *
235 */
236 mod(y: Numeric): Decimal;
237
238 /**
239 * Return a new Decimal whose value is the natural exponential of the value of this Decimal,
240 * i.e. the base e raised to the power the value of this Decimal, truncated to `precision`
241 * significant digits.
242 *
243 */
244 naturalExponetial(): Decimal;
245
246 /**
247 * Return a new Decimal whose value is the natural exponential of the value of this Decimal,
248 * i.e. the base e raised to the power the value of this Decimal, truncated to `precision`
249 * significant digits.
250 *
251 */
252 exp(): Decimal;
253
254 /**
255 * Return a new Decimal whose value is the natural logarithm of the value of this Decimal,
256 * truncated to `precision` significant digits.
257 *
258 */
259 naturalLogarithm(): Decimal;
260
261 /**
262 * Return a new Decimal whose value is the natural logarithm of the value of this Decimal,
263 * truncated to `precision` significant digits.
264 *
265 */
266 ln(): Decimal;
267
268 /**
269 * Return a new Decimal whose value is the value of this Decimal negated, i.e. as if multiplied by
270 * -1.
271 *
272 */
273 negated(): Decimal;
274
275 /**
276 * Return a new Decimal whose value is the value of this Decimal negated, i.e. as if multiplied by
277 * -1.
278 *
279 */
280 neg(): Decimal;
281
282 /**
283 * Return a new Decimal whose value is the value of this Decimal plus `y`, truncated to
284 * `precision` significant digits.
285 *
286 */
287 plus(y: Numeric): Decimal;
288
289 /**
290 * Return a new Decimal whose value is the value of this Decimal plus `y`, truncated to
291 * `precision` significant digits.
292 *
293 */
294 add(y: Numeric): Decimal;
295
296 /**
297 * Return the number of significant digits of the value of this Decimal.
298 *
299 * @param zeros {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
300 */
301 precision(zeros: boolean|number): number;
302
303 /**
304 * Return the number of significant digits of the value of this Decimal.
305 *
306 * @param zeros {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
307 */
308 sd(zeros: boolean|number): number;
309
310 /**
311 * Return a new Decimal whose value is the square root of this Decimal, truncated to `precision`
312 * significant digits.
313 *
314 */
315 squareRoot(): Decimal;
316
317 /**
318 * Return a new Decimal whose value is the square root of this Decimal, truncated to `precision`
319 * significant digits.
320 *
321 */
322 sqrt(): Decimal;
323
324 /**
325 * Return a new Decimal whose value is the value of this Decimal times `y`, truncated to
326 * `precision` significant digits.
327 *
328 */
329 times(y: Numeric): Decimal;
330
331 /**
332 * Return a new Decimal whose value is the value of this Decimal times `y`, truncated to
333 * `precision` significant digits.
334 *
335 */
336 mul(y: Numeric): Decimal;
337
338 /**
339 * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `dp`
340 * decimal places using rounding mode `rm` or `rounding` if `rm` is omitted.
341 *
342 * If `dp` is omitted, return a new Decimal whose value is the value of this Decimal.
343 *
344 * @param dp {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
345 * @param rm {number} Rounding mode. Integer, 0 to 8 inclusive.
346 *
347 */
348 toDecimalPlaces(dp?: number, rm?: number): Decimal;
349
350 /**
351 * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `dp`
352 * decimal places using rounding mode `rm` or `rounding` if `rm` is omitted.
353 *
354 * If `dp` is omitted, return a new Decimal whose value is the value of this Decimal.
355 *
356 * @param dp {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
357 * @param rm {number} Rounding mode. Integer, 0 to 8 inclusive.
358 *
359 */
360 todp(dp?: number, rm?: number): Decimal;
361
362 /**
363 * Return a string representing the value of this Decimal in exponential notation rounded to
364 * `dp` fixed decimal places using rounding mode `rounding`.
365 *
366 * @param dp {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
367 * @param rm {number} Rounding mode. Integer, 0 to 8 inclusive.
368 *
369 */
370 toExponential(dp?: number, rm?: number): string;
371
372 /**
373 * Return a string representing the value of this Decimal in normal (fixed-point) notation to
374 * `dp` fixed decimal places and rounded using rounding mode `rm` or `rounding` if `rm` is
375 * omitted.
376 *
377 * As with JavaScript numbers, (-0).toFixed(0) is '0', but e.g. (-0.00001).toFixed(0) is '-0'.
378 *
379 * @param dp {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
380 * @param rm {number} Rounding mode. Integer, 0 to 8 inclusive.
381 *
382 * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
383 * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
384 * (-0).toFixed(3) is '0.000'.
385 * (-0.5).toFixed(0) is '-0'.
386 *
387 */
388 toFixed(dp?: number, rm?: number): string;
389
390 /**
391 * Return a new Decimal whose value is the value of this Decimal rounded to a whole number using
392 * rounding mode `rounding`.
393 *
394 */
395 toInteger(): Decimal;
396
397 /**
398 * Return a new Decimal whose value is the value of this Decimal rounded to a whole number using
399 * rounding mode `rounding`.
400 *
401 */
402 toint(): Decimal;
403
404 /**
405 * Return the value of this Decimal converted to a number primitive.
406 *
407 */
408 toNumber(): number;
409
410 /**
411 * Return a new Decimal whose value is the value of this Decimal raised to the power `y`,
412 * truncated to `precision` significant digits.
413 *
414 * For non-integer or very large exponents pow(x, y) is calculated using
415 *
416 * x^y = exp(y*ln(x))
417 *
418 * The maximum error is 1 ulp (unit in last place).
419 *
420 * @param y {number|string|Decimal} The power to which to raise this Decimal.
421 *
422 */
423 toPower(y: Numeric): Decimal;
424
425 /**
426 * Return a new Decimal whose value is the value of this Decimal raised to the power `y`,
427 * truncated to `precision` significant digits.
428 *
429 * For non-integer or very large exponents pow(x, y) is calculated using
430 *
431 * x^y = exp(y*ln(x))
432 *
433 * The maximum error is 1 ulp (unit in last place).
434 *
435 * @param y {number|string|Decimal} The power to which to raise this Decimal.
436 *
437 */
438 pow(y: Numeric): Decimal;
439
440 /**
441 * Return a string representing the value of this Decimal rounded to `sd` significant digits
442 * using rounding mode `rounding`.
443 *
444 * Return exponential notation if `sd` is less than the number of digits necessary to represent
445 * the integer part of the value in normal notation.
446 *
447 * @param sd {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
448 * @param rm {number} Rounding mode. Integer, 0 to 8 inclusive.
449 *
450 */
451 toPrecision(sd?: number, rm?: number): string;
452
453 /**
454 * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `sd`
455 * significant digits using rounding mode `rm`, or to `precision` and `rounding` respectively if
456 * omitted.
457 *
458 * @param sd {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
459 * @param rm {number} Rounding mode. Integer, 0 to 8 inclusive.
460 *
461 */
462 toSignificantDigits(sd?: number, rm?: number): Decimal;
463
464 /**
465 * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `sd`
466 * significant digits using rounding mode `rm`, or to `precision` and `rounding` respectively if
467 * omitted.
468 *
469 * @param sd {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
470 * @param rm {number} Rounding mode. Integer, 0 to 8 inclusive.
471 *
472 */
473 tosd(sd?: number, rm?: number): Decimal;
474
475 /**
476 * Return a string representing the value of this Decimal.
477 *
478 * Return exponential notation if this Decimal has a positive exponent equal to or greater than
479 * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`.
480 *
481 */
482 toString(): string;
483
484 /**
485 * Return a string representing the value of this Decimal.
486 *
487 * Return exponential notation if this Decimal has a positive exponent equal to or greater than
488 * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`.
489 *
490 */
491 valueOf(): string;
492
493 /**
494 * Return a string representing the value of this Decimal.
495 *
496 * Return exponential notation if this Decimal has a positive exponent equal to or greater than
497 * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`.
498 *
499 */
500 val(): string;
501
502 /**
503 * Return a string representing the value of this Decimal.
504 *
505 * Return exponential notation if this Decimal has a positive exponent equal to or greater than
506 * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`.
507 *
508 */
509 toJSON(): string;
510
511 /**
512 * Create and return a Decimal constructor with the same configuration properties as this Decimal
513 * constructor.
514 *
515 * @param config? Config
516 */
517 static clone(config?: Config): typeof Decimal;
518
519 /**
520 * Configure global settings for a Decimal constructor.
521 */
522 static config(config: Config): Decimal;
523
524 /**
525 * Configure global settings for a Decimal constructor.
526 */
527 static set(config: Config): Decimal;
528
529 // The maximum number of significant digits of the result of a calculation or base conversion.
530 // E.g. `Decimal.config({ precision: 20 });`
531 static precision: number;
532
533 // The rounding mode used by default by `toInteger`, `toDecimalPlaces`, `toExponential`,
534 // `toFixed`, `toPrecision` and `toSignificantDigits`.
535 //
536 // E.g.
537 // `Decimal.rounding = 4;`
538 // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
539 static rounding: number;
540 static readonly ROUND_UP: number;
541 static readonly ROUND_DOWN: number;
542 static readonly ROUND_CEIL: number;
543 static readonly ROUND_FLOOR: number;
544 static readonly ROUND_HALF_UP: number;
545 static readonly ROUND_HALF_DOWN: number;
546 static readonly ROUND_HALF_EVEN: number;
547 static readonly ROUND_HALF_CEIL: number;
548 static readonly ROUND_HALF_FLOOR: number;
549
550 // The exponent value at and beneath which `toString` returns exponential notation.
551 // JavaScript numbers: -7
552 static toExpNeg: number; // 0 to -MAX_E
553
554 // The exponent value at and above which `toString` returns exponential notation.
555 // JavaScript numbers: 21
556 static toExpPos: number; // 0 to MAX_E
557
558 // The natural logarithm of 10.
559 static LN10: Decimal;
560}
561
562export interface Config {
563 precision?: number;
564 rounding?: number;
565 toExpNeg?: number;
566 toExpPos?: number;
567 LN10?: Numeric;
568}
569
570export type Numeric = string|number|Decimal;
Note: See TracBrowser for help on using the repository browser.