5
5
6
6
// Documentation: http://mikemcl.github.io/bignumber.js/
7
7
//
8
- // Exports:
9
- //
10
- // class BigNumber (default export)
8
+ // class BigNumber
11
9
// type BigNumber.Constructor
12
10
// type BigNumber.ModuloMode
13
11
// type BigNumber.RoundingMode
31
29
//
32
30
// The use of compiler option `--strictNullChecks` is recommended.
33
31
34
- export default BigNumber ;
35
-
36
- export namespace BigNumber {
32
+ declare namespace BigNumber {
37
33
38
34
/** See `BigNumber.config` (alias `BigNumber.set`) and `BigNumber.clone`. */
39
35
interface Config {
@@ -324,10 +320,10 @@ export namespace BigNumber {
324
320
type Constructor = typeof BigNumber ;
325
321
type ModuloMode = 0 | 1 | 3 | 6 | 9 ;
326
322
type RoundingMode = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 ;
327
- type Value = string | number | Instance ;
323
+ type Value = string | number | bigint | Instance ;
328
324
}
329
325
330
- export declare class BigNumber implements BigNumber . Instance {
326
+ declare class BigNumber implements BigNumber . Instance {
331
327
332
328
/** Used internally to identify a BigNumber instance. */
333
329
private readonly _isBigNumber : true ;
@@ -343,7 +339,7 @@ export declare class BigNumber implements BigNumber.Instance {
343
339
344
340
/**
345
341
* Returns a new instance of a BigNumber object with value `n`, where `n` is a numeric value in
346
- * the specified `base`, or base 10 if `base` is omitted or is `null` or `undefined` .
342
+ * the specified `base`, or base 10 if `base` is omitted.
347
343
*
348
344
* ```ts
349
345
* x = new BigNumber(123.4567) // '123.4567'
@@ -485,17 +481,16 @@ export declare class BigNumber implements BigNumber.Instance {
485
481
* @param n A numeric value.
486
482
* @param [base] The base of n.
487
483
*/
488
- comparedTo ( n : BigNumber . Value , base ?: number ) : number ;
484
+ comparedTo ( n : BigNumber . Value , base ?: number ) : 1 | - 1 | 0 | null ;
489
485
490
486
/**
491
487
* Returns a BigNumber whose value is the value of this BigNumber rounded by rounding mode
492
488
* `roundingMode` to a maximum of `decimalPlaces` decimal places.
493
489
*
494
- * If `decimalPlaces` is omitted, or is `null` or `undefined`, the return value is the number of
495
- * decimal places of the value of this BigNumber, or `null` if the value of this BigNumber is
496
- * ±`Infinity` or `NaN`.
490
+ * If `decimalPlaces` is omitted, the return value is the number of decimal places of the value of
491
+ * this BigNumber, or `null` if the value of this BigNumber is ±`Infinity` or `NaN`.
497
492
*
498
- * If `roundingMode` is omitted, or is `null` or `undefined`, `ROUNDING_MODE` is used.
493
+ * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
499
494
*
500
495
* Throws if `decimalPlaces` or `roundingMode` is invalid.
501
496
*
@@ -524,11 +519,10 @@ export declare class BigNumber implements BigNumber.Instance {
524
519
* Returns a BigNumber whose value is the value of this BigNumber rounded by rounding mode
525
520
* `roundingMode` to a maximum of `decimalPlaces` decimal places.
526
521
*
527
- * If `decimalPlaces` is omitted, or is `null` or `undefined`, the return value is the number of
528
- * decimal places of the value of this BigNumber, or `null` if the value of this BigNumber is
529
- * ±`Infinity` or `NaN`.
522
+ * If `decimalPlaces` is omitted, the return value is the number of decimal places of the value of
523
+ * this BigNumber, or `null` if the value of this BigNumber is ±`Infinity` or `NaN`.
530
524
*
531
- * If `roundingMode` is omitted, or is `null` or `undefined`, `ROUNDING_MODE` is used.
525
+ * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
532
526
*
533
527
* Throws if `decimalPlaces` or `roundingMode` is invalid.
534
528
*
@@ -693,7 +687,7 @@ export declare class BigNumber implements BigNumber.Instance {
693
687
* Returns a BigNumber whose value is the value of this BigNumber rounded to an integer using
694
688
* rounding mode `rm`.
695
689
*
696
- * If `rm` is omitted, or is `null` or `undefined`, `ROUNDING_MODE` is used.
690
+ * If `rm` is omitted, `ROUNDING_MODE` is used.
697
691
*
698
692
* Throws if `rm` is invalid.
699
693
*
@@ -790,7 +784,7 @@ export declare class BigNumber implements BigNumber.Instance {
790
784
* returns `false`.
791
785
*
792
786
* ```ts
793
- * 0.1 > (0.3 - 0 // true
787
+ * 0.1 > (0.3 - 0.2) // true
794
788
* x = new BigNumber(0.1)
795
789
* x.gt(BigNumber(0.3).minus(0.2)) // false
796
790
* BigNumber(0).gt(x) // false
@@ -1122,7 +1116,7 @@ export declare class BigNumber implements BigNumber.Instance {
1122
1116
* Returns a BigNumber whose value is the value of this BigNumber rounded to a precision of
1123
1117
* `significantDigits` significant digits using rounding mode `roundingMode`.
1124
1118
*
1125
- * If `roundingMode` is omitted or is `null` or `undefined` , `ROUNDING_MODE` will be used.
1119
+ * If `roundingMode` is omitted, `ROUNDING_MODE` will be used.
1126
1120
*
1127
1121
* Throws if `significantDigits` or `roundingMode` is invalid.
1128
1122
*
@@ -1166,7 +1160,7 @@ export declare class BigNumber implements BigNumber.Instance {
1166
1160
* Returns a BigNumber whose value is the value of this BigNumber rounded to a precision of
1167
1161
* `significantDigits` significant digits using rounding mode `roundingMode`.
1168
1162
*
1169
- * If `roundingMode` is omitted or is `null` or `undefined` , `ROUNDING_MODE` will be used.
1163
+ * If `roundingMode` is omitted, `ROUNDING_MODE` will be used.
1170
1164
*
1171
1165
* Throws if `significantDigits` or `roundingMode` is invalid.
1172
1166
*
@@ -1244,11 +1238,10 @@ export declare class BigNumber implements BigNumber.Instance {
1244
1238
* If the value of this BigNumber in exponential notation has fewer than `decimalPlaces` fraction
1245
1239
* digits, the return value will be appended with zeros accordingly.
1246
1240
*
1247
- * If `decimalPlaces` is omitted, or is `null` or `undefined`, the number of digits after the
1248
- * decimal point defaults to the minimum number of digits necessary to represent the value
1249
- * exactly.
1241
+ * If `decimalPlaces` is omitted, the number of digits after the decimal point defaults to the
1242
+ * minimum number of digits necessary to represent the value exactly.
1250
1243
*
1251
- * If `roundingMode` is omitted or is `null` or `undefined` , `ROUNDING_MODE` is used.
1244
+ * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
1252
1245
*
1253
1246
* Throws if `decimalPlaces` or `roundingMode` is invalid.
1254
1247
*
@@ -1282,12 +1275,12 @@ export declare class BigNumber implements BigNumber.Instance {
1282
1275
* Unlike `Number.prototype.toFixed`, which returns exponential notation if a number is greater or
1283
1276
* equal to 10**21, this method will always return normal notation.
1284
1277
*
1285
- * If `decimalPlaces` is omitted or is `null` or `undefined` , the return value will be unrounded
1286
- * and in normal notation. This is also unlike `Number.prototype.toFixed`, which returns the value
1287
- * to zero decimal places. It is useful when normal notation is required and the current
1288
- * `EXPONENTIAL_AT` setting causes ` toString` to return exponential notation.
1278
+ * If `decimalPlaces` is omitted, the return value will be unrounded and in normal notation.
1279
+ * This is also unlike `Number.prototype.toFixed`, which returns the value to zero decimal places.
1280
+ * It is useful when normal notation is required and the current `EXPONENTIAL_AT` setting causes
1281
+ * `toString` to return exponential notation.
1289
1282
*
1290
- * If `roundingMode` is omitted or is `null` or `undefined` , `ROUNDING_MODE` is used.
1283
+ * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
1291
1284
*
1292
1285
* Throws if `decimalPlaces` or `roundingMode` is invalid.
1293
1286
*
@@ -1317,12 +1310,12 @@ export declare class BigNumber implements BigNumber.Instance {
1317
1310
*
1318
1311
* The formatting object may contain some or all of the properties shown in the examples below.
1319
1312
*
1320
- * If `decimalPlaces` is omitted or is `null` or `undefined` , then the return value is not
1321
- * rounded to a fixed number of decimal places.
1313
+ * If `decimalPlaces` is omitted, then the return value is not rounded to a fixed number of
1314
+ * decimal places.
1322
1315
*
1323
- * If `roundingMode` is omitted or is `null` or `undefined` , `ROUNDING_MODE` is used.
1316
+ * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
1324
1317
*
1325
- * If `format` is omitted or is `null` or `undefined` , `FORMAT` is used.
1318
+ * If `format` is omitted, `FORMAT` is used.
1326
1319
*
1327
1320
* Throws if `decimalPlaces`, `roundingMode`, or `format` is invalid.
1328
1321
*
@@ -1378,8 +1371,8 @@ export declare class BigNumber implements BigNumber.Instance {
1378
1371
* Returns an array of two BigNumbers representing the value of this BigNumber as a simple
1379
1372
* fraction with an integer numerator and an integer denominator.
1380
1373
* The denominator will be a positive non-zero value less than or equal to `max_denominator`.
1381
- * If a maximum denominator, `max_denominator`, is not specified, or is `null` or `undefined`, the
1382
- * denominator will be the lowest value necessary to represent the number exactly.
1374
+ * If a maximum denominator, `max_denominator`, is not specified, the denominator will be the
1375
+ * lowest value necessary to represent the number exactly.
1383
1376
*
1384
1377
* Throws if `max_denominator` is invalid.
1385
1378
*
@@ -1430,10 +1423,9 @@ export declare class BigNumber implements BigNumber.Instance {
1430
1423
* If `significantDigits` is less than the number of digits necessary to represent the integer
1431
1424
* part of the value in normal (fixed-point) notation, then exponential notation is used.
1432
1425
*
1433
- * If `significantDigits` is omitted, or is `null` or `undefined`, then the return value is the
1434
- * same as `n.toString()`.
1426
+ * If `significantDigits` is omitted, then the return value is the same as `n.toString()`.
1435
1427
*
1436
- * If `roundingMode` is omitted or is `null` or `undefined` , `ROUNDING_MODE` is used.
1428
+ * If `roundingMode` is omitted, `ROUNDING_MODE` is used.
1437
1429
*
1438
1430
* Throws if `significantDigits` or `roundingMode` is invalid.
1439
1431
*
@@ -1458,7 +1450,7 @@ export declare class BigNumber implements BigNumber.Instance {
1458
1450
1459
1451
/**
1460
1452
* Returns a string representing the value of this BigNumber in base `base`, or base 10 if `base`
1461
- * is omitted or is `null` or `undefined` .
1453
+ * is omitted.
1462
1454
*
1463
1455
* For bases above 10, and using the default base conversion alphabet (see `ALPHABET`), values
1464
1456
* from 10 to 35 are represented by a-z (the same as `Number.prototype.toString`).
@@ -1471,8 +1463,6 @@ export declare class BigNumber implements BigNumber.Instance {
1471
1463
* exponent equal to or less than the negative component of the setting, then exponential notation
1472
1464
* is returned.
1473
1465
*
1474
- * If `base` is `null` or `undefined` it is ignored.
1475
- *
1476
1466
* Throws if `base` is invalid.
1477
1467
*
1478
1468
* ```ts
@@ -1592,7 +1582,7 @@ export declare class BigNumber implements BigNumber.Instance {
1592
1582
1593
1583
/**
1594
1584
* Returns a new independent BigNumber constructor with configuration as described by `object`, or
1595
- * with the default configuration if object is `null` or `undefined` .
1585
+ * with the default configuration if object is omitted .
1596
1586
*
1597
1587
* Throws if `object` is not an object.
1598
1588
*
@@ -1828,4 +1818,4 @@ export declare class BigNumber implements BigNumber.Instance {
1828
1818
static set ( object ?: BigNumber . Config ) : BigNumber . Config ;
1829
1819
}
1830
1820
1831
- export function BigNumber ( n : BigNumber . Value , base ?: number ) : BigNumber ;
1821
+ declare function BigNumber ( n : BigNumber . Value , base ?: number ) : BigNumber ;
0 commit comments