powiaina_num.js 0.2.13 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -384,6 +384,7 @@ var PowiainaNum = /*#__PURE__*/function () {
384
384
  } catch (e) {
385
385
  console.error("Malformed input");
386
386
  console.error(e);
387
+ if (PowiainaNum.throwErrorOnResultNaN && PowiainaNum.isNaN(this)) throw new Error("NaN");
387
388
  }
388
389
  }
389
390
  //#region 4 Basic calculates.
@@ -398,7 +399,10 @@ var PowiainaNum = /*#__PURE__*/function () {
398
399
  var x = this.clone().normalize();
399
400
  var y = new PowiainaNum(other);
400
401
  // inf + -inf = nan
401
- if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY)) return PowiainaNum.NaN.clone();
402
+ if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY)) {
403
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
404
+ return PowiainaNum.NaN.clone();
405
+ }
402
406
  // inf & nan check
403
407
  if (!x.isFinite()) return x.clone();
404
408
  if (!y.isFinite()) return y.clone();
@@ -495,7 +499,10 @@ var PowiainaNum = /*#__PURE__*/function () {
495
499
  var y = new PowiainaNum(other);
496
500
  // inf * -inf = -inf
497
501
  if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || y.eq(PowiainaNum.POSITIVE_INFINITY) && x.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.NEGATIVE_INFINITY.clone();
498
- if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero()) return PowiainaNum.NaN.clone();
502
+ if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero()) {
503
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
504
+ return PowiainaNum.NaN.clone();
505
+ }
499
506
  if (x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.POSITIVE_INFINITY.clone();
500
507
  // inf & nan check
501
508
  if (!x.isFinite()) return x.clone();
@@ -600,6 +607,7 @@ var PowiainaNum = /*#__PURE__*/function () {
600
607
  return this.neg().pow(other).neg();
601
608
  }
602
609
  }
610
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
603
611
  return PowiainaNum.NaN.clone();
604
612
  }
605
613
  var r = this.abs().pow(other);
@@ -629,6 +637,7 @@ var PowiainaNum = /*#__PURE__*/function () {
629
637
  } else if (other.rec().mod(2).eq(1)) {
630
638
  return this.neg().log10().mul(other).pow10().neg();
631
639
  }
640
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
632
641
  return PowiainaNum.NaN.clone();
633
642
  }
634
643
  }, {
@@ -656,7 +665,10 @@ var PowiainaNum = /*#__PURE__*/function () {
656
665
  }, {
657
666
  key: "log10",
658
667
  value: function log10() {
659
- if (this.isneg()) return PowiainaNum.NaN.clone();
668
+ if (this.isneg()) {
669
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
670
+ return PowiainaNum.NaN.clone();
671
+ }
660
672
  if (this.isZero()) return PowiainaNum.NEGATIVE_INFINITY.clone();
661
673
  if (this.small) {
662
674
  var _x = this.clone();
@@ -798,6 +810,7 @@ var PowiainaNum = /*#__PURE__*/function () {
798
810
  var princ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
799
811
  var principal = princ;
800
812
  if (this.lt(-0.3678794411710499)) {
813
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
801
814
  return PowiainaNum.NaN.clone(); //complex
802
815
  } else if (principal) {
803
816
  if (this.abs().lt("1e-300")) return new PowiainaNum(this);else if (this.small) {
@@ -812,6 +825,7 @@ var PowiainaNum = /*#__PURE__*/function () {
812
825
  }
813
826
  } else {
814
827
  if (this.sign === -1) {
828
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
815
829
  return PowiainaNum.NaN.clone(); //complex
816
830
  }
817
831
  if (this.lt(9e15)) {
@@ -835,7 +849,10 @@ var PowiainaNum = /*#__PURE__*/function () {
835
849
  var t = this.clone();
836
850
  var other = new PowiainaNum(other2);
837
851
  var payl = new PowiainaNum(payload);
838
- if (t.isNaN() || other.isNaN() || payl.isNaN()) return PowiainaNum.NaN.clone();
852
+ if (t.isNaN() || other.isNaN() || payl.isNaN()) {
853
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
854
+ return PowiainaNum.NaN.clone();
855
+ }
839
856
  if (t.eq(1)) return PowiainaNum.ONE.clone();
840
857
  if (payl.neq(PowiainaNum.ONE) && t.gte(EXP_E_REC)) {
841
858
  other = other.add(payl.slog(t));
@@ -846,14 +863,23 @@ var PowiainaNum = /*#__PURE__*/function () {
846
863
  negln = this.log().neg();
847
864
  return negln.lambertw().div(negln);
848
865
  }
849
- if (other.lte(-2)) return PowiainaNum.NaN.clone();
866
+ if (other.lte(-2)) {
867
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
868
+ return PowiainaNum.NaN.clone();
869
+ }
850
870
  if (t.isZero()) {
851
- if (other.isZero()) return PowiainaNum.NaN.clone();
871
+ if (other.isZero()) {
872
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
873
+ return PowiainaNum.NaN.clone();
874
+ }
852
875
  if (other.gte(MSI / 2) || other.toNumber() % 2 == 0) return PowiainaNum.ZERO.clone();
853
876
  return PowiainaNum.ONE.clone();
854
877
  }
855
878
  if (t.eq(PowiainaNum.ONE)) {
856
- if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.NaN.clone();
879
+ if (other.eq(PowiainaNum.ONE.neg())) {
880
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
881
+ return PowiainaNum.NaN.clone();
882
+ }
857
883
  return PowiainaNum.ONE.clone();
858
884
  }
859
885
  if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.ZERO.clone();
@@ -927,7 +953,10 @@ var PowiainaNum = /*#__PURE__*/function () {
927
953
  if (b.lt(EXP_E_REC)) {
928
954
  var a = b.tetrate(Infinity);
929
955
  if (x.eq(a)) return PowiainaNum.POSITIVE_INFINITY.clone();
930
- if (x.gt(a)) return PowiainaNum.NaN.clone();
956
+ if (x.gt(a)) {
957
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
958
+ return PowiainaNum.NaN.clone();
959
+ }
931
960
  }
932
961
  if (x.max(b).gt(PowiainaNum.PENTATED_MSI)) {
933
962
  if (x.gt(b)) return x;
@@ -971,13 +1000,17 @@ var PowiainaNum = /*#__PURE__*/function () {
971
1000
  }
972
1001
  }
973
1002
  if (x.gt(10)) return new PowiainaNum(r);
1003
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
974
1004
  return PowiainaNum.NaN.clone();
975
1005
  }
976
1006
  }, {
977
1007
  key: "ssqrt",
978
1008
  value: function ssqrt() {
979
1009
  var x = this.clone();
980
- if (x.lt(1 / EXP_E_REC)) return PowiainaNum.NaN.clone();
1010
+ if (x.lt(1 / EXP_E_REC)) {
1011
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1012
+ return PowiainaNum.NaN.clone();
1013
+ }
981
1014
  if (!x.isFinite()) return x;
982
1015
  if (x.gt(PowiainaNum.TETRATED_MSI)) return x;
983
1016
  if (x.gt(PowiainaNum.EE_MSI)) {
@@ -1028,6 +1061,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1028
1061
  if (!arrows.isInt() || arrows.lt(PowiainaNum.ZERO)) {
1029
1062
  console.warn("The arrow is <0 or not a integer, the returned function will return NaN.");
1030
1063
  return function () {
1064
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1031
1065
  return PowiainaNum.NaN.clone();
1032
1066
  };
1033
1067
  }
@@ -1053,6 +1087,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1053
1087
  if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
1054
1088
  if (t.eq(PowiainaNum.ZERO)) {
1055
1089
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
1090
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1056
1091
  return PowiainaNum.NaN.clone();
1057
1092
  }
1058
1093
  if (payload.neq(PowiainaNum.ONE)) other = other.add(payload.anyarrow_log(arrows)(t));
@@ -1132,6 +1167,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1132
1167
  throw new Error(powiainaNumError + "Not implemented");
1133
1168
  }
1134
1169
  if (!arrow.isInt() || arrow.lt(0)) return function () {
1170
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1135
1171
  return PowiainaNum.NaN.clone();
1136
1172
  };
1137
1173
  if (arrow.eq(0)) return function (base) {
@@ -1165,7 +1201,10 @@ var PowiainaNum = /*#__PURE__*/function () {
1165
1201
  return x.sub(x.getOperator(arrowsNum - 1));
1166
1202
  }
1167
1203
  }
1168
- if (x.lt(PowiainaNum.ZERO.clone())) return PowiainaNum.NaN.clone();
1204
+ if (x.lt(PowiainaNum.ZERO.clone())) {
1205
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1206
+ return PowiainaNum.NaN.clone();
1207
+ }
1169
1208
  // base^base^... = x? (? bases)
1170
1209
  var r = 0;
1171
1210
  // 计算x与base的差距
@@ -1189,6 +1228,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1189
1228
  }
1190
1229
  }
1191
1230
  if (x.gt(10)) return new PowiainaNum(r);
1231
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1192
1232
  return PowiainaNum.NaN.clone();
1193
1233
  };
1194
1234
  }
@@ -1248,7 +1288,10 @@ var PowiainaNum = /*#__PURE__*/function () {
1248
1288
  if (other.lt(PowiainaNum.ZERO) || !other.isInt()) return PowiainaNum.NaN.clone();
1249
1289
  if (other.eq(PowiainaNum.ONE)) return this.clone();
1250
1290
  if (this.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
1251
- if (!this.isInt()) return PowiainaNum.NaN.clone();
1291
+ if (!this.isInt()) {
1292
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1293
+ return PowiainaNum.NaN.clone();
1294
+ }
1252
1295
  if (this.eq(2)) return new PowiainaNum(4);
1253
1296
  if (other.eq(0)) return PowiainaNum.ONE.clone();
1254
1297
  var r;
@@ -1288,6 +1331,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1288
1331
  var arrow = new PowiainaNum(arrow2);
1289
1332
  var t = this.clone();
1290
1333
  if (arrow.lt(0) || !arrow.isInt() || arrow.isNaN() || this.isNaN()) return function () {
1334
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1291
1335
  return PowiainaNum.NaN.clone();
1292
1336
  };
1293
1337
  if (arrow.eq(0)) return function (other) {
@@ -1302,9 +1346,13 @@ var PowiainaNum = /*#__PURE__*/function () {
1302
1346
  var other = new PowiainaNum(other2);
1303
1347
  var r;
1304
1348
  if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
1305
- if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
1349
+ if (other.lt(PowiainaNum.ZERO)) {
1350
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1351
+ return PowiainaNum.NaN.clone();
1352
+ }
1306
1353
  if (t.eq(PowiainaNum.ZERO)) {
1307
1354
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
1355
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1308
1356
  return PowiainaNum.NaN.clone();
1309
1357
  }
1310
1358
  if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
@@ -1493,7 +1541,8 @@ var PowiainaNum = /*#__PURE__*/function () {
1493
1541
  /**
1494
1542
  * -1: `this` is smaller
1495
1543
  * 0: equals
1496
- * 1: `x` is bigger
1544
+ * 1: `x` is smaller
1545
+ * 2: NaN
1497
1546
  */
1498
1547
  }, {
1499
1548
  key: "compare",
@@ -1502,6 +1551,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1502
1551
  if (this.isNaN() || other.isNaN()) return 2;
1503
1552
  if (this.sign < other.sign) return -1;
1504
1553
  if (this.sign > other.sign) return 1;
1554
+ var t = this;
1505
1555
  //this.sign = other.sign
1506
1556
  var allneg = this.sign == -1 && other.sign == -1;
1507
1557
  if (this.small && !other.small) return -1 * (allneg ? -1 : 1);
@@ -1513,6 +1563,10 @@ var PowiainaNum = /*#__PURE__*/function () {
1513
1563
  for (var i = 0; this.array.length - 1 - i >= 0 && other.array.length - 1 - i >= 0; i++) {
1514
1564
  var op1 = this.array[this.array.length - 1 - i];
1515
1565
  var op2 = other.array[other.array.length - 1 - i];
1566
+ if (op1.repeat === Infinity && op2.repeat === Infinity) {
1567
+ if (t.small === other.small) return 0;
1568
+ return other.small ? 1 : -1;
1569
+ }
1516
1570
  if (op1.repeat === Infinity) {
1517
1571
  result = 1;
1518
1572
  break;
@@ -2453,7 +2507,10 @@ var PowiainaNum = /*#__PURE__*/function () {
2453
2507
  if (base.eq(1)) return new PowiainaNum(1);
2454
2508
  if (power.eq(1)) return new PowiainaNum(base);
2455
2509
  if (power.isZero()) return new PowiainaNum(1);
2456
- if (base.lt(0)) return PowiainaNum.NaN.clone();
2510
+ if (base.lt(0)) {
2511
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
2512
+ return PowiainaNum.NaN.clone();
2513
+ }
2457
2514
  // // check infinite
2458
2515
  // let sufpowiaina = args.slice(4);
2459
2516
  // if (sufpowiaina.filter((f) => new PowiainaNum(f).gte(2)).length > 0) {
@@ -2523,6 +2580,7 @@ var PowiainaNum = /*#__PURE__*/function () {
2523
2580
  if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
2524
2581
  if (t.eq(PowiainaNum.ZERO)) {
2525
2582
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
2583
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
2526
2584
  return PowiainaNum.NaN.clone();
2527
2585
  }
2528
2586
  if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
@@ -2744,7 +2802,7 @@ var PowiainaNum = /*#__PURE__*/function () {
2744
2802
  }, {
2745
2803
  key: "fromNumber",
2746
2804
  value: function fromNumber(x) {
2747
- var obj = new PowiainaNum(); // NaN
2805
+ var obj = new PowiainaNum();
2748
2806
  obj.resetFromObject({
2749
2807
  array: [{
2750
2808
  arrow: 0,
@@ -2756,6 +2814,7 @@ var PowiainaNum = /*#__PURE__*/function () {
2756
2814
  layer: 0,
2757
2815
  sign: 0
2758
2816
  });
2817
+ if (Number.isNaN(x)) return obj;
2759
2818
  if (x < 0) obj.sign = -1; // negative
2760
2819
  else if (x == 0) {
2761
2820
  obj.sign = 0;
@@ -3302,13 +3361,18 @@ PowiainaNum.POW_2_44_MOD_PI = 1.701173079953;
3302
3361
  PowiainaNum.arrowFuncMap = new Map();
3303
3362
  //#region configurations
3304
3363
  /**
3305
- * If you set this config to true, the `fromString` method will try to parse the string to `PowiainaNum` class with `break_eternity.js` similar `fromString` method, if cannot parse correctly, the program will use `PowiainaNum.js` `fromString` method.
3364
+ * If you set this config to true,
3365
+ * the `fromString` method will try to parse the string to `PowiainaNum` class with `break_eternity.js` similar `fromString` method, if cannot parse correctly, the program will use `PowiainaNum.js` `fromString` method.
3306
3366
  */
3307
- PowiainaNum.usingBreakEternityLikeFromString = false;
3367
+ PowiainaNum.usingBreakEternityLikeFromString = true;
3308
3368
  /**
3309
3369
  * If you set this config to true, the `constructor` method will return Zero instead of NaN when call new PowiainaNum() with no arguments.
3310
3370
  */
3311
3371
  PowiainaNum.blankArgumentConstructorReturnZero = false;
3372
+ /**
3373
+ * If you set this config to true, when calucation returns NaN, the program will throw error.
3374
+ */
3375
+ PowiainaNum.throwErrorOnResultNaN = false;
3312
3376
 
3313
3377
  exports.arraySortFunction = arraySortFunction;
3314
3378
  exports["default"] = PowiainaNum;
@@ -380,6 +380,7 @@ var PowiainaNum = /*#__PURE__*/function () {
380
380
  } catch (e) {
381
381
  console.error("Malformed input");
382
382
  console.error(e);
383
+ if (PowiainaNum.throwErrorOnResultNaN && PowiainaNum.isNaN(this)) throw new Error("NaN");
383
384
  }
384
385
  }
385
386
  //#region 4 Basic calculates.
@@ -394,7 +395,10 @@ var PowiainaNum = /*#__PURE__*/function () {
394
395
  var x = this.clone().normalize();
395
396
  var y = new PowiainaNum(other);
396
397
  // inf + -inf = nan
397
- if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY)) return PowiainaNum.NaN.clone();
398
+ if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY)) {
399
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
400
+ return PowiainaNum.NaN.clone();
401
+ }
398
402
  // inf & nan check
399
403
  if (!x.isFinite()) return x.clone();
400
404
  if (!y.isFinite()) return y.clone();
@@ -491,7 +495,10 @@ var PowiainaNum = /*#__PURE__*/function () {
491
495
  var y = new PowiainaNum(other);
492
496
  // inf * -inf = -inf
493
497
  if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || y.eq(PowiainaNum.POSITIVE_INFINITY) && x.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.NEGATIVE_INFINITY.clone();
494
- if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero()) return PowiainaNum.NaN.clone();
498
+ if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero()) {
499
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
500
+ return PowiainaNum.NaN.clone();
501
+ }
495
502
  if (x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.POSITIVE_INFINITY.clone();
496
503
  // inf & nan check
497
504
  if (!x.isFinite()) return x.clone();
@@ -596,6 +603,7 @@ var PowiainaNum = /*#__PURE__*/function () {
596
603
  return this.neg().pow(other).neg();
597
604
  }
598
605
  }
606
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
599
607
  return PowiainaNum.NaN.clone();
600
608
  }
601
609
  var r = this.abs().pow(other);
@@ -625,6 +633,7 @@ var PowiainaNum = /*#__PURE__*/function () {
625
633
  } else if (other.rec().mod(2).eq(1)) {
626
634
  return this.neg().log10().mul(other).pow10().neg();
627
635
  }
636
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
628
637
  return PowiainaNum.NaN.clone();
629
638
  }
630
639
  }, {
@@ -652,7 +661,10 @@ var PowiainaNum = /*#__PURE__*/function () {
652
661
  }, {
653
662
  key: "log10",
654
663
  value: function log10() {
655
- if (this.isneg()) return PowiainaNum.NaN.clone();
664
+ if (this.isneg()) {
665
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
666
+ return PowiainaNum.NaN.clone();
667
+ }
656
668
  if (this.isZero()) return PowiainaNum.NEGATIVE_INFINITY.clone();
657
669
  if (this.small) {
658
670
  var _x = this.clone();
@@ -794,6 +806,7 @@ var PowiainaNum = /*#__PURE__*/function () {
794
806
  var princ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
795
807
  var principal = princ;
796
808
  if (this.lt(-0.3678794411710499)) {
809
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
797
810
  return PowiainaNum.NaN.clone(); //complex
798
811
  } else if (principal) {
799
812
  if (this.abs().lt("1e-300")) return new PowiainaNum(this);else if (this.small) {
@@ -808,6 +821,7 @@ var PowiainaNum = /*#__PURE__*/function () {
808
821
  }
809
822
  } else {
810
823
  if (this.sign === -1) {
824
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
811
825
  return PowiainaNum.NaN.clone(); //complex
812
826
  }
813
827
  if (this.lt(9e15)) {
@@ -831,7 +845,10 @@ var PowiainaNum = /*#__PURE__*/function () {
831
845
  var t = this.clone();
832
846
  var other = new PowiainaNum(other2);
833
847
  var payl = new PowiainaNum(payload);
834
- if (t.isNaN() || other.isNaN() || payl.isNaN()) return PowiainaNum.NaN.clone();
848
+ if (t.isNaN() || other.isNaN() || payl.isNaN()) {
849
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
850
+ return PowiainaNum.NaN.clone();
851
+ }
835
852
  if (t.eq(1)) return PowiainaNum.ONE.clone();
836
853
  if (payl.neq(PowiainaNum.ONE) && t.gte(EXP_E_REC)) {
837
854
  other = other.add(payl.slog(t));
@@ -842,14 +859,23 @@ var PowiainaNum = /*#__PURE__*/function () {
842
859
  negln = this.log().neg();
843
860
  return negln.lambertw().div(negln);
844
861
  }
845
- if (other.lte(-2)) return PowiainaNum.NaN.clone();
862
+ if (other.lte(-2)) {
863
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
864
+ return PowiainaNum.NaN.clone();
865
+ }
846
866
  if (t.isZero()) {
847
- if (other.isZero()) return PowiainaNum.NaN.clone();
867
+ if (other.isZero()) {
868
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
869
+ return PowiainaNum.NaN.clone();
870
+ }
848
871
  if (other.gte(MSI / 2) || other.toNumber() % 2 == 0) return PowiainaNum.ZERO.clone();
849
872
  return PowiainaNum.ONE.clone();
850
873
  }
851
874
  if (t.eq(PowiainaNum.ONE)) {
852
- if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.NaN.clone();
875
+ if (other.eq(PowiainaNum.ONE.neg())) {
876
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
877
+ return PowiainaNum.NaN.clone();
878
+ }
853
879
  return PowiainaNum.ONE.clone();
854
880
  }
855
881
  if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.ZERO.clone();
@@ -923,7 +949,10 @@ var PowiainaNum = /*#__PURE__*/function () {
923
949
  if (b.lt(EXP_E_REC)) {
924
950
  var a = b.tetrate(Infinity);
925
951
  if (x.eq(a)) return PowiainaNum.POSITIVE_INFINITY.clone();
926
- if (x.gt(a)) return PowiainaNum.NaN.clone();
952
+ if (x.gt(a)) {
953
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
954
+ return PowiainaNum.NaN.clone();
955
+ }
927
956
  }
928
957
  if (x.max(b).gt(PowiainaNum.PENTATED_MSI)) {
929
958
  if (x.gt(b)) return x;
@@ -967,13 +996,17 @@ var PowiainaNum = /*#__PURE__*/function () {
967
996
  }
968
997
  }
969
998
  if (x.gt(10)) return new PowiainaNum(r);
999
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
970
1000
  return PowiainaNum.NaN.clone();
971
1001
  }
972
1002
  }, {
973
1003
  key: "ssqrt",
974
1004
  value: function ssqrt() {
975
1005
  var x = this.clone();
976
- if (x.lt(1 / EXP_E_REC)) return PowiainaNum.NaN.clone();
1006
+ if (x.lt(1 / EXP_E_REC)) {
1007
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1008
+ return PowiainaNum.NaN.clone();
1009
+ }
977
1010
  if (!x.isFinite()) return x;
978
1011
  if (x.gt(PowiainaNum.TETRATED_MSI)) return x;
979
1012
  if (x.gt(PowiainaNum.EE_MSI)) {
@@ -1024,6 +1057,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1024
1057
  if (!arrows.isInt() || arrows.lt(PowiainaNum.ZERO)) {
1025
1058
  console.warn("The arrow is <0 or not a integer, the returned function will return NaN.");
1026
1059
  return function () {
1060
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1027
1061
  return PowiainaNum.NaN.clone();
1028
1062
  };
1029
1063
  }
@@ -1049,6 +1083,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1049
1083
  if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
1050
1084
  if (t.eq(PowiainaNum.ZERO)) {
1051
1085
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
1086
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1052
1087
  return PowiainaNum.NaN.clone();
1053
1088
  }
1054
1089
  if (payload.neq(PowiainaNum.ONE)) other = other.add(payload.anyarrow_log(arrows)(t));
@@ -1128,6 +1163,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1128
1163
  throw new Error(powiainaNumError + "Not implemented");
1129
1164
  }
1130
1165
  if (!arrow.isInt() || arrow.lt(0)) return function () {
1166
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1131
1167
  return PowiainaNum.NaN.clone();
1132
1168
  };
1133
1169
  if (arrow.eq(0)) return function (base) {
@@ -1161,7 +1197,10 @@ var PowiainaNum = /*#__PURE__*/function () {
1161
1197
  return x.sub(x.getOperator(arrowsNum - 1));
1162
1198
  }
1163
1199
  }
1164
- if (x.lt(PowiainaNum.ZERO.clone())) return PowiainaNum.NaN.clone();
1200
+ if (x.lt(PowiainaNum.ZERO.clone())) {
1201
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1202
+ return PowiainaNum.NaN.clone();
1203
+ }
1165
1204
  // base^base^... = x? (? bases)
1166
1205
  var r = 0;
1167
1206
  // 计算x与base的差距
@@ -1185,6 +1224,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1185
1224
  }
1186
1225
  }
1187
1226
  if (x.gt(10)) return new PowiainaNum(r);
1227
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1188
1228
  return PowiainaNum.NaN.clone();
1189
1229
  };
1190
1230
  }
@@ -1244,7 +1284,10 @@ var PowiainaNum = /*#__PURE__*/function () {
1244
1284
  if (other.lt(PowiainaNum.ZERO) || !other.isInt()) return PowiainaNum.NaN.clone();
1245
1285
  if (other.eq(PowiainaNum.ONE)) return this.clone();
1246
1286
  if (this.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
1247
- if (!this.isInt()) return PowiainaNum.NaN.clone();
1287
+ if (!this.isInt()) {
1288
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1289
+ return PowiainaNum.NaN.clone();
1290
+ }
1248
1291
  if (this.eq(2)) return new PowiainaNum(4);
1249
1292
  if (other.eq(0)) return PowiainaNum.ONE.clone();
1250
1293
  var r;
@@ -1284,6 +1327,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1284
1327
  var arrow = new PowiainaNum(arrow2);
1285
1328
  var t = this.clone();
1286
1329
  if (arrow.lt(0) || !arrow.isInt() || arrow.isNaN() || this.isNaN()) return function () {
1330
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1287
1331
  return PowiainaNum.NaN.clone();
1288
1332
  };
1289
1333
  if (arrow.eq(0)) return function (other) {
@@ -1298,9 +1342,13 @@ var PowiainaNum = /*#__PURE__*/function () {
1298
1342
  var other = new PowiainaNum(other2);
1299
1343
  var r;
1300
1344
  if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
1301
- if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
1345
+ if (other.lt(PowiainaNum.ZERO)) {
1346
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1347
+ return PowiainaNum.NaN.clone();
1348
+ }
1302
1349
  if (t.eq(PowiainaNum.ZERO)) {
1303
1350
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
1351
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1304
1352
  return PowiainaNum.NaN.clone();
1305
1353
  }
1306
1354
  if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
@@ -1489,7 +1537,8 @@ var PowiainaNum = /*#__PURE__*/function () {
1489
1537
  /**
1490
1538
  * -1: `this` is smaller
1491
1539
  * 0: equals
1492
- * 1: `x` is bigger
1540
+ * 1: `x` is smaller
1541
+ * 2: NaN
1493
1542
  */
1494
1543
  }, {
1495
1544
  key: "compare",
@@ -1498,6 +1547,7 @@ var PowiainaNum = /*#__PURE__*/function () {
1498
1547
  if (this.isNaN() || other.isNaN()) return 2;
1499
1548
  if (this.sign < other.sign) return -1;
1500
1549
  if (this.sign > other.sign) return 1;
1550
+ var t = this;
1501
1551
  //this.sign = other.sign
1502
1552
  var allneg = this.sign == -1 && other.sign == -1;
1503
1553
  if (this.small && !other.small) return -1 * (allneg ? -1 : 1);
@@ -1509,6 +1559,10 @@ var PowiainaNum = /*#__PURE__*/function () {
1509
1559
  for (var i = 0; this.array.length - 1 - i >= 0 && other.array.length - 1 - i >= 0; i++) {
1510
1560
  var op1 = this.array[this.array.length - 1 - i];
1511
1561
  var op2 = other.array[other.array.length - 1 - i];
1562
+ if (op1.repeat === Infinity && op2.repeat === Infinity) {
1563
+ if (t.small === other.small) return 0;
1564
+ return other.small ? 1 : -1;
1565
+ }
1512
1566
  if (op1.repeat === Infinity) {
1513
1567
  result = 1;
1514
1568
  break;
@@ -2449,7 +2503,10 @@ var PowiainaNum = /*#__PURE__*/function () {
2449
2503
  if (base.eq(1)) return new PowiainaNum(1);
2450
2504
  if (power.eq(1)) return new PowiainaNum(base);
2451
2505
  if (power.isZero()) return new PowiainaNum(1);
2452
- if (base.lt(0)) return PowiainaNum.NaN.clone();
2506
+ if (base.lt(0)) {
2507
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
2508
+ return PowiainaNum.NaN.clone();
2509
+ }
2453
2510
  // // check infinite
2454
2511
  // let sufpowiaina = args.slice(4);
2455
2512
  // if (sufpowiaina.filter((f) => new PowiainaNum(f).gte(2)).length > 0) {
@@ -2519,6 +2576,7 @@ var PowiainaNum = /*#__PURE__*/function () {
2519
2576
  if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
2520
2577
  if (t.eq(PowiainaNum.ZERO)) {
2521
2578
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
2579
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
2522
2580
  return PowiainaNum.NaN.clone();
2523
2581
  }
2524
2582
  if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
@@ -2740,7 +2798,7 @@ var PowiainaNum = /*#__PURE__*/function () {
2740
2798
  }, {
2741
2799
  key: "fromNumber",
2742
2800
  value: function fromNumber(x) {
2743
- var obj = new PowiainaNum(); // NaN
2801
+ var obj = new PowiainaNum();
2744
2802
  obj.resetFromObject({
2745
2803
  array: [{
2746
2804
  arrow: 0,
@@ -2752,6 +2810,7 @@ var PowiainaNum = /*#__PURE__*/function () {
2752
2810
  layer: 0,
2753
2811
  sign: 0
2754
2812
  });
2813
+ if (Number.isNaN(x)) return obj;
2755
2814
  if (x < 0) obj.sign = -1; // negative
2756
2815
  else if (x == 0) {
2757
2816
  obj.sign = 0;
@@ -3298,12 +3357,17 @@ PowiainaNum.POW_2_44_MOD_PI = 1.701173079953;
3298
3357
  PowiainaNum.arrowFuncMap = new Map();
3299
3358
  //#region configurations
3300
3359
  /**
3301
- * If you set this config to true, the `fromString` method will try to parse the string to `PowiainaNum` class with `break_eternity.js` similar `fromString` method, if cannot parse correctly, the program will use `PowiainaNum.js` `fromString` method.
3360
+ * If you set this config to true,
3361
+ * the `fromString` method will try to parse the string to `PowiainaNum` class with `break_eternity.js` similar `fromString` method, if cannot parse correctly, the program will use `PowiainaNum.js` `fromString` method.
3302
3362
  */
3303
- PowiainaNum.usingBreakEternityLikeFromString = false;
3363
+ PowiainaNum.usingBreakEternityLikeFromString = true;
3304
3364
  /**
3305
3365
  * If you set this config to true, the `constructor` method will return Zero instead of NaN when call new PowiainaNum() with no arguments.
3306
3366
  */
3307
3367
  PowiainaNum.blankArgumentConstructorReturnZero = false;
3368
+ /**
3369
+ * If you set this config to true, when calucation returns NaN, the program will throw error.
3370
+ */
3371
+ PowiainaNum.throwErrorOnResultNaN = false;
3308
3372
 
3309
3373
  export { arraySortFunction, PowiainaNum as default, mergeSameArrays };
@@ -386,6 +386,7 @@
386
386
  } catch (e) {
387
387
  console.error("Malformed input");
388
388
  console.error(e);
389
+ if (PowiainaNum.throwErrorOnResultNaN && PowiainaNum.isNaN(this)) throw new Error("NaN");
389
390
  }
390
391
  }
391
392
  //#region 4 Basic calculates.
@@ -400,7 +401,10 @@
400
401
  var x = this.clone().normalize();
401
402
  var y = new PowiainaNum(other);
402
403
  // inf + -inf = nan
403
- if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY)) return PowiainaNum.NaN.clone();
404
+ if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY)) {
405
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
406
+ return PowiainaNum.NaN.clone();
407
+ }
404
408
  // inf & nan check
405
409
  if (!x.isFinite()) return x.clone();
406
410
  if (!y.isFinite()) return y.clone();
@@ -497,7 +501,10 @@
497
501
  var y = new PowiainaNum(other);
498
502
  // inf * -inf = -inf
499
503
  if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || y.eq(PowiainaNum.POSITIVE_INFINITY) && x.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.NEGATIVE_INFINITY.clone();
500
- if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero()) return PowiainaNum.NaN.clone();
504
+ if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero()) {
505
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
506
+ return PowiainaNum.NaN.clone();
507
+ }
501
508
  if (x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.POSITIVE_INFINITY.clone();
502
509
  // inf & nan check
503
510
  if (!x.isFinite()) return x.clone();
@@ -602,6 +609,7 @@
602
609
  return this.neg().pow(other).neg();
603
610
  }
604
611
  }
612
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
605
613
  return PowiainaNum.NaN.clone();
606
614
  }
607
615
  var r = this.abs().pow(other);
@@ -631,6 +639,7 @@
631
639
  } else if (other.rec().mod(2).eq(1)) {
632
640
  return this.neg().log10().mul(other).pow10().neg();
633
641
  }
642
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
634
643
  return PowiainaNum.NaN.clone();
635
644
  }
636
645
  }, {
@@ -658,7 +667,10 @@
658
667
  }, {
659
668
  key: "log10",
660
669
  value: function log10() {
661
- if (this.isneg()) return PowiainaNum.NaN.clone();
670
+ if (this.isneg()) {
671
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
672
+ return PowiainaNum.NaN.clone();
673
+ }
662
674
  if (this.isZero()) return PowiainaNum.NEGATIVE_INFINITY.clone();
663
675
  if (this.small) {
664
676
  var _x = this.clone();
@@ -800,6 +812,7 @@
800
812
  var princ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
801
813
  var principal = princ;
802
814
  if (this.lt(-0.3678794411710499)) {
815
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
803
816
  return PowiainaNum.NaN.clone(); //complex
804
817
  } else if (principal) {
805
818
  if (this.abs().lt("1e-300")) return new PowiainaNum(this);else if (this.small) {
@@ -814,6 +827,7 @@
814
827
  }
815
828
  } else {
816
829
  if (this.sign === -1) {
830
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
817
831
  return PowiainaNum.NaN.clone(); //complex
818
832
  }
819
833
  if (this.lt(9e15)) {
@@ -837,7 +851,10 @@
837
851
  var t = this.clone();
838
852
  var other = new PowiainaNum(other2);
839
853
  var payl = new PowiainaNum(payload);
840
- if (t.isNaN() || other.isNaN() || payl.isNaN()) return PowiainaNum.NaN.clone();
854
+ if (t.isNaN() || other.isNaN() || payl.isNaN()) {
855
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
856
+ return PowiainaNum.NaN.clone();
857
+ }
841
858
  if (t.eq(1)) return PowiainaNum.ONE.clone();
842
859
  if (payl.neq(PowiainaNum.ONE) && t.gte(EXP_E_REC)) {
843
860
  other = other.add(payl.slog(t));
@@ -848,14 +865,23 @@
848
865
  negln = this.log().neg();
849
866
  return negln.lambertw().div(negln);
850
867
  }
851
- if (other.lte(-2)) return PowiainaNum.NaN.clone();
868
+ if (other.lte(-2)) {
869
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
870
+ return PowiainaNum.NaN.clone();
871
+ }
852
872
  if (t.isZero()) {
853
- if (other.isZero()) return PowiainaNum.NaN.clone();
873
+ if (other.isZero()) {
874
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
875
+ return PowiainaNum.NaN.clone();
876
+ }
854
877
  if (other.gte(MSI / 2) || other.toNumber() % 2 == 0) return PowiainaNum.ZERO.clone();
855
878
  return PowiainaNum.ONE.clone();
856
879
  }
857
880
  if (t.eq(PowiainaNum.ONE)) {
858
- if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.NaN.clone();
881
+ if (other.eq(PowiainaNum.ONE.neg())) {
882
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
883
+ return PowiainaNum.NaN.clone();
884
+ }
859
885
  return PowiainaNum.ONE.clone();
860
886
  }
861
887
  if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.ZERO.clone();
@@ -929,7 +955,10 @@
929
955
  if (b.lt(EXP_E_REC)) {
930
956
  var a = b.tetrate(Infinity);
931
957
  if (x.eq(a)) return PowiainaNum.POSITIVE_INFINITY.clone();
932
- if (x.gt(a)) return PowiainaNum.NaN.clone();
958
+ if (x.gt(a)) {
959
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
960
+ return PowiainaNum.NaN.clone();
961
+ }
933
962
  }
934
963
  if (x.max(b).gt(PowiainaNum.PENTATED_MSI)) {
935
964
  if (x.gt(b)) return x;
@@ -973,13 +1002,17 @@
973
1002
  }
974
1003
  }
975
1004
  if (x.gt(10)) return new PowiainaNum(r);
1005
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
976
1006
  return PowiainaNum.NaN.clone();
977
1007
  }
978
1008
  }, {
979
1009
  key: "ssqrt",
980
1010
  value: function ssqrt() {
981
1011
  var x = this.clone();
982
- if (x.lt(1 / EXP_E_REC)) return PowiainaNum.NaN.clone();
1012
+ if (x.lt(1 / EXP_E_REC)) {
1013
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1014
+ return PowiainaNum.NaN.clone();
1015
+ }
983
1016
  if (!x.isFinite()) return x;
984
1017
  if (x.gt(PowiainaNum.TETRATED_MSI)) return x;
985
1018
  if (x.gt(PowiainaNum.EE_MSI)) {
@@ -1030,6 +1063,7 @@
1030
1063
  if (!arrows.isInt() || arrows.lt(PowiainaNum.ZERO)) {
1031
1064
  console.warn("The arrow is <0 or not a integer, the returned function will return NaN.");
1032
1065
  return function () {
1066
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1033
1067
  return PowiainaNum.NaN.clone();
1034
1068
  };
1035
1069
  }
@@ -1055,6 +1089,7 @@
1055
1089
  if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
1056
1090
  if (t.eq(PowiainaNum.ZERO)) {
1057
1091
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
1092
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1058
1093
  return PowiainaNum.NaN.clone();
1059
1094
  }
1060
1095
  if (payload.neq(PowiainaNum.ONE)) other = other.add(payload.anyarrow_log(arrows)(t));
@@ -1134,6 +1169,7 @@
1134
1169
  throw new Error(powiainaNumError + "Not implemented");
1135
1170
  }
1136
1171
  if (!arrow.isInt() || arrow.lt(0)) return function () {
1172
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1137
1173
  return PowiainaNum.NaN.clone();
1138
1174
  };
1139
1175
  if (arrow.eq(0)) return function (base) {
@@ -1167,7 +1203,10 @@
1167
1203
  return x.sub(x.getOperator(arrowsNum - 1));
1168
1204
  }
1169
1205
  }
1170
- if (x.lt(PowiainaNum.ZERO.clone())) return PowiainaNum.NaN.clone();
1206
+ if (x.lt(PowiainaNum.ZERO.clone())) {
1207
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1208
+ return PowiainaNum.NaN.clone();
1209
+ }
1171
1210
  // base^base^... = x? (? bases)
1172
1211
  var r = 0;
1173
1212
  // 计算x与base的差距
@@ -1191,6 +1230,7 @@
1191
1230
  }
1192
1231
  }
1193
1232
  if (x.gt(10)) return new PowiainaNum(r);
1233
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1194
1234
  return PowiainaNum.NaN.clone();
1195
1235
  };
1196
1236
  }
@@ -1250,7 +1290,10 @@
1250
1290
  if (other.lt(PowiainaNum.ZERO) || !other.isInt()) return PowiainaNum.NaN.clone();
1251
1291
  if (other.eq(PowiainaNum.ONE)) return this.clone();
1252
1292
  if (this.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
1253
- if (!this.isInt()) return PowiainaNum.NaN.clone();
1293
+ if (!this.isInt()) {
1294
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1295
+ return PowiainaNum.NaN.clone();
1296
+ }
1254
1297
  if (this.eq(2)) return new PowiainaNum(4);
1255
1298
  if (other.eq(0)) return PowiainaNum.ONE.clone();
1256
1299
  var r;
@@ -1290,6 +1333,7 @@
1290
1333
  var arrow = new PowiainaNum(arrow2);
1291
1334
  var t = this.clone();
1292
1335
  if (arrow.lt(0) || !arrow.isInt() || arrow.isNaN() || this.isNaN()) return function () {
1336
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1293
1337
  return PowiainaNum.NaN.clone();
1294
1338
  };
1295
1339
  if (arrow.eq(0)) return function (other) {
@@ -1304,9 +1348,13 @@
1304
1348
  var other = new PowiainaNum(other2);
1305
1349
  var r;
1306
1350
  if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
1307
- if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
1351
+ if (other.lt(PowiainaNum.ZERO)) {
1352
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1353
+ return PowiainaNum.NaN.clone();
1354
+ }
1308
1355
  if (t.eq(PowiainaNum.ZERO)) {
1309
1356
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
1357
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1310
1358
  return PowiainaNum.NaN.clone();
1311
1359
  }
1312
1360
  if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
@@ -1495,7 +1543,8 @@
1495
1543
  /**
1496
1544
  * -1: `this` is smaller
1497
1545
  * 0: equals
1498
- * 1: `x` is bigger
1546
+ * 1: `x` is smaller
1547
+ * 2: NaN
1499
1548
  */
1500
1549
  }, {
1501
1550
  key: "compare",
@@ -1504,6 +1553,7 @@
1504
1553
  if (this.isNaN() || other.isNaN()) return 2;
1505
1554
  if (this.sign < other.sign) return -1;
1506
1555
  if (this.sign > other.sign) return 1;
1556
+ var t = this;
1507
1557
  //this.sign = other.sign
1508
1558
  var allneg = this.sign == -1 && other.sign == -1;
1509
1559
  if (this.small && !other.small) return -1 * (allneg ? -1 : 1);
@@ -1515,6 +1565,10 @@
1515
1565
  for (var i = 0; this.array.length - 1 - i >= 0 && other.array.length - 1 - i >= 0; i++) {
1516
1566
  var op1 = this.array[this.array.length - 1 - i];
1517
1567
  var op2 = other.array[other.array.length - 1 - i];
1568
+ if (op1.repeat === Infinity && op2.repeat === Infinity) {
1569
+ if (t.small === other.small) return 0;
1570
+ return other.small ? 1 : -1;
1571
+ }
1518
1572
  if (op1.repeat === Infinity) {
1519
1573
  result = 1;
1520
1574
  break;
@@ -2455,7 +2509,10 @@
2455
2509
  if (base.eq(1)) return new PowiainaNum(1);
2456
2510
  if (power.eq(1)) return new PowiainaNum(base);
2457
2511
  if (power.isZero()) return new PowiainaNum(1);
2458
- if (base.lt(0)) return PowiainaNum.NaN.clone();
2512
+ if (base.lt(0)) {
2513
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
2514
+ return PowiainaNum.NaN.clone();
2515
+ }
2459
2516
  // // check infinite
2460
2517
  // let sufpowiaina = args.slice(4);
2461
2518
  // if (sufpowiaina.filter((f) => new PowiainaNum(f).gte(2)).length > 0) {
@@ -2525,6 +2582,7 @@
2525
2582
  if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
2526
2583
  if (t.eq(PowiainaNum.ZERO)) {
2527
2584
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
2585
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
2528
2586
  return PowiainaNum.NaN.clone();
2529
2587
  }
2530
2588
  if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
@@ -2746,7 +2804,7 @@
2746
2804
  }, {
2747
2805
  key: "fromNumber",
2748
2806
  value: function fromNumber(x) {
2749
- var obj = new PowiainaNum(); // NaN
2807
+ var obj = new PowiainaNum();
2750
2808
  obj.resetFromObject({
2751
2809
  array: [{
2752
2810
  arrow: 0,
@@ -2758,6 +2816,7 @@
2758
2816
  layer: 0,
2759
2817
  sign: 0
2760
2818
  });
2819
+ if (Number.isNaN(x)) return obj;
2761
2820
  if (x < 0) obj.sign = -1; // negative
2762
2821
  else if (x == 0) {
2763
2822
  obj.sign = 0;
@@ -3304,13 +3363,18 @@
3304
3363
  PowiainaNum.arrowFuncMap = new Map();
3305
3364
  //#region configurations
3306
3365
  /**
3307
- * If you set this config to true, the `fromString` method will try to parse the string to `PowiainaNum` class with `break_eternity.js` similar `fromString` method, if cannot parse correctly, the program will use `PowiainaNum.js` `fromString` method.
3366
+ * If you set this config to true,
3367
+ * the `fromString` method will try to parse the string to `PowiainaNum` class with `break_eternity.js` similar `fromString` method, if cannot parse correctly, the program will use `PowiainaNum.js` `fromString` method.
3308
3368
  */
3309
- PowiainaNum.usingBreakEternityLikeFromString = false;
3369
+ PowiainaNum.usingBreakEternityLikeFromString = true;
3310
3370
  /**
3311
3371
  * If you set this config to true, the `constructor` method will return Zero instead of NaN when call new PowiainaNum() with no arguments.
3312
3372
  */
3313
3373
  PowiainaNum.blankArgumentConstructorReturnZero = false;
3374
+ /**
3375
+ * If you set this config to true, when calucation returns NaN, the program will throw error.
3376
+ */
3377
+ PowiainaNum.throwErrorOnResultNaN = false;
3314
3378
 
3315
3379
  exports.arraySortFunction = arraySortFunction;
3316
3380
  exports["default"] = PowiainaNum;
@@ -1 +1 @@
1
- !function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).PowiainaNum={})}(this,(function(r){"use strict";function e(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,a=Array(e);t<e;t++)a[t]=r[t];return a}function t(r,e){for(var t=0;t<e.length;t++){var a=e[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(r,n(a.key),a)}}function a(r){return function(r){if(Array.isArray(r))return e(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||function(r,t){if(r){if("string"==typeof r)return e(r,t);var a={}.toString.call(r).slice(8,-1);return"Object"===a&&r.constructor&&(a=r.constructor.name),"Map"===a||"Set"===a?Array.from(r):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(r,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(r){var e=function(r,e){if("object"!=typeof r||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var a=t.call(r,e||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==typeof e?e:e+""}function i(r){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var o,u=9007199254740991,l=15.954589770191003,s=11102230246251568e-32,c=1.444667861009766,f=/^(PN)?[\/\-\+]*(Infinity|NaN|(P+|P\^\d+ )?(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})|\(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})\)\^[1-9]\d*\x20*)*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/,g=/^((\d+(\.\d*)?|\d*\.\d+)?([EeFf]([-\+]?)))*(0|\d+(\.\d*)?|\d*\.\d+)$/;function h(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{repeat:r,arrow:e,expans:t,megota:a,valuereplaced:e==1/0?0:t==1/0?1:-1}}function y(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];for(var a=0;a<Math.min(e[0].length,e[1].length);a++){var n=e[0][a],i=e[1][a];if(n<i)return-1;if(n>i)return 1}return 0}function p(r){return Math.log10(Number(r.substring(0,17)))+(r.length-17)}var m=.5671432904097838;function v(r){var e,t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=a,o=n;if(!Number.isFinite(r))return r;if(o){if(0===r)return r;if(1===r)return m;e=r<10?0:Math.log(r)-Math.log(Math.log(r))}else{if(0===r)return-1/0;e=r<=-.1?-2:Math.log(-r)-Math.log(-Math.log(-r))}for(var u=0;u<100;++u){if(t=(r*Math.exp(-e)+e*e)/(e+1),Math.abs(t-e)<i*Math.abs(t))return t;e=t}throw Error("Iteration failed to converge: ".concat(r.toString()))}function N(r){return 2==r.length}function w(r){return"number"==typeof r[0]&&"number"==typeof r[1]}function b(r){return"x"===r?1/0:r}function d(r){return 4==r.length}function O(r){return"number"==typeof r[0]&&"number"==typeof r[1]&&"number"==typeof r[2]&&"number"==typeof r[3]}function E(r){return"x"===r[0]&&"number"==typeof r[1]&&"number"==typeof r[2]&&"number"==typeof r[3]}function I(r){return"number"==typeof r[0]&&"number"==typeof r[1]&&"x"==r[2]&&"number"==typeof r[3]}function k(r){var e,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e10,a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!(r=new q(r)).isFinite())return r;if(a){if(r.eq(q.ZERO))return r;if(r.eq(q.ONE))return new q(m);e=q.log(r)}else{if(r.eq(q.ZERO))return q.NEGATIVE_INFINITY.clone();e=q.log(r.neg())}for(var n=0;n<100;++n){var i=e.neg().exp(),o=e.sub(r.mul(i)),u=e.add(q.ONE).sub(e.add(2).mul(o).div(q.mul(2,e).add(2)));if(u.eq(q.ZERO))return e;var l=e.sub(o.div(u));if(q.abs(l.sub(e)).lt(q.abs(l).mul(t)))return l;e=l}throw Error("Iteration failed to converge: "+r)}function x(r,e){return y([r.megota,r.expans,r.arrow],[e.megota,e.expans,e.arrow])}var M,q=function(){function r(e){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),this[o]="PowiainaNum",this.array=[{arrow:0,expans:1,megota:1,repeat:NaN}],this.small=!1,this.sign=0,this.layer=0,r.blankArgumentConstructorReturnZero&&this.resetFromObject(r.ZERO);try{if(void 0===e);else if("number"==typeof e){var t=r.fromNumber(e);this.resetFromObject(t)}else if("object"==i(e)){var a=r.fromObject(e);this.resetFromObject(a)}else if("string"==typeof e){var n=r.fromString(e);this.resetFromObject(n)}else;}catch(r){console.error("Malformed input"),console.error(r)}}return function(r,e,a){return e&&t(r.prototype,e),a&&t(r,a),Object.defineProperty(r,"prototype",{writable:!1}),r}(r,[{key:"add",value:function(e){var t,a,n,i,o,c,f=this.clone().normalize(),g=new r(e);if(f.eq(r.POSITIVE_INFINITY)&&g.eq(r.NEGATIVE_INFINITY)||f.eq(r.NEGATIVE_INFINITY)&&g.eq(r.POSITIVE_INFINITY))return r.NaN.clone();if(!f.isFinite())return f.clone();if(!g.isFinite())return g.clone();if(f.isZero())return g.clone();if(g.isZero())return f.clone();if(f.sign==-g.sign&&function(){var r=f.abs(),e=g.abs();return r.eq(e)}())return r.ZERO.clone();if(f.abs().lt(u)&&g.abs().lt(u)&&f.abs().gte(s)&&g.abs().gte(s))return r.fromNumber(f.toNumber()+g.toNumber());if(f.abs().lt(r.E_MSI_REC)||f.abs().gt(r.E_MSI)||g.abs().lt(r.E_MSI_REC)||g.abs().gt(r.E_MSI)){var y=f.maxabs(g);return f.abs().eq(y)?f:(g.abs().eq(y),g)}if(-1==f.sign)return f.neg().add(g.neg()).neg();f.cmpabs(g)>0?(o=f,c=g):(c=f,o=g);var p=o.toNumber()+c.toNumber();if(isFinite(p)&&0!==p)return r.fromNumber(p);var m=1;if(!(o.small||c.small||(null===(t=o.array[1])||void 0===t?void 0:t.repeat)||(null===(a=c.array[1])||void 0===a?void 0:a.repeat)||o.sign!=c.sign))return new r((o.array[0].repeat+c.array[0].repeat)*o.sign);var v=(o.small?-1:1)*((null===(n=o.array[1])||void 0===n?void 0:n.repeat)?o.array[0].repeat:Math.log10(o.array[0].repeat)),N=(c.small?-1:1)*((null===(i=c.array[1])||void 0===i?void 0:i.repeat)?c.array[0].repeat:Math.log10(c.array[0].repeat));if(v-N>l)return o;var w=-Math.floor(v),b=0,d=o.sign*Math.pow(10,v+w)+c.sign*Math.pow(10,N+w);if(d>0&&(b=Math.log10(d)-w),d<0&&(b=Math.log10(-d)-w,m*=-1),0==d)return r.ZERO.clone();var O=r.NaN.clone();return O.sign=1,O.array=b>l||b<-l?[h(b,0),h(1,1)]:[h(Math.pow(10,Math.abs(b)),0)],O.small=b<0,O.sign*=m,O}},{key:"plus",value:function(r){return this.add(r)}},{key:"sub",value:function(e){return this.add(new r(e).neg())}},{key:"minus",value:function(r){return this.sub(r)}},{key:"mul",value:function(e){var t=this.clone(),a=new r(e);if(t.eq(r.POSITIVE_INFINITY)&&a.eq(r.NEGATIVE_INFINITY)||a.eq(r.POSITIVE_INFINITY)&&t.eq(r.NEGATIVE_INFINITY))return r.NEGATIVE_INFINITY.clone();if(t.isInfiNaN()&&a.isZero()||a.isInfiNaN()&&t.isZero())return r.NaN.clone();if(t.eq(r.NEGATIVE_INFINITY)&&a.eq(r.NEGATIVE_INFINITY))return r.POSITIVE_INFINITY.clone();if(!t.isFinite())return t.clone();if(!a.isFinite())return a.clone();if(t.isZero()||a.isZero())return r.ZERO.clone();var n,i=t.toNumber()*a.toNumber();return isFinite(i)&&0!==i?r.fromNumber(i):((n=t.abs().log10().add(a.abs().log10()).pow10()).sign=t.sign*a.sign,n)}},{key:"times",value:function(r){return this.mul(r)}},{key:"div",value:function(e){var t=new r(e).rec();return this.mul(t)}},{key:"divide",value:function(r){return this.div(r)}},{key:"mod",value:function(e){var t=new r(e),a=this.div(t);return a.sub(a.floor()).mul(t)}},{key:"modulus",value:function(r){return this.mod(r)}},{key:"pow10",value:function(){var e,t,a=this.clone();return this.isFinite()?a.isneg()?(a.sign*=-1,a.pow10().rec()):a.lte(308.25471555991675)?r.fromNumber(Math.pow(10,a.toNumber())):a.small?a.lt(r.MSI_REC)?r.ONE:new r(Math.pow(10,Math.pow(a.array[0].repeat,-1))):(a.gt(r.TETRATED_MSI)||(a.setOperator((null!==(t=null===(e=a.array[1])||void 0===e?void 0:e.repeat)&&void 0!==t?t:0)+1,1),a.normalize()),a):this.clone()}},{key:"pow",value:function(e){var t=new r(e);if(this.eq(1))return r.ONE.clone();if(!t.isFinite())return t.clone();if(!this.isFinite())return this.clone();if(this.eq(10))return t.pow10();if(t.isneg())return this.pow(t.neg()).rec();if(this.isneg()){if(!t.isInt())return t.small&&t.rec().div(2).eq(1)?this.neg().pow(t).neg():r.NaN.clone();var a=this.abs().pow(t);return a.sign=function(){var r=t.mod(2).round();return r.eq(0)||r.eq(2)?1:-1}(),a}var n=this.toNumber(),i=t.toNumber(),o=Math.pow(n,i);return isFinite(o)&&0!==o?r.fromNumber(o):this.isZero()&&t.isZero()?r.ONE.clone():this.isZero()?r.ZERO.clone():t.isZero()?r.ONE.clone():this.gt(0)?this.log10().mul(t).pow10():t.rec().mod(2).eq(1)?this.neg().log10().mul(t).pow10().neg():r.NaN.clone()}},{key:"pow_base",value:function(e){return new r(e).pow(this)}},{key:"root",value:function(e){var t=new r(e);return this.pow(t.rec())}},{key:"sqrt",value:function(){return this.pow(.5)}},{key:"cbrt",value:function(){return this.abs().root(3).mul(this.sign)}},{key:"log10",value:function(){if(this.isneg())return r.NaN.clone();if(this.isZero())return r.NEGATIVE_INFINITY.clone();if(this.small){var e=this.clone();return e.small=!e.small,e.log10().neg()}if(1==this.array.length)return new r(Math.log10(this.array[0].repeat));if(this.gte(r.TETRATED_MSI))return this.clone();var t=this.clone();return t.array[1].repeat=t.array[1].repeat-1,t.normalize(),t}},{key:"log",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.E,t=new r(e);return this.log10().div(t.log10())}},{key:"log2",value:function(){return this.log(2)}},{key:"logBase",value:function(r){return this.log(r)}},{key:"ln",value:function(){return this.log()}},{key:"pLog10",value:function(){return this.isneg()?r.ZERO:this.log10()}},{key:"exp",value:function(){return this.pow_base(Math.E)}},{key:"factorial",value:function(){return this.abs().lt(u)?this.add(1).gamma():this.abs().lt(r.E_MSI)?r.exp(this.mul(this.log10().sub(1))):r.exp(this)}},{key:"gamma",value:function(){if(this.small)return this.rec();if(this.lte(u)){if(this.lt(24))return r.fromNumber(function(r){if(!isFinite(r))return r;if(r<-50)return r===Math.trunc(r)?Number.NEGATIVE_INFINITY:0;for(var e=1;r<10;)e*=r,++r;var t=.9189385332046727;t+=((r-=1)+.5)*Math.log(r),t-=r;var a=r*r,n=r;return t+=1/(12*n),t-=1/(360*(n*=a)),t+=1/(1260*(n*=a)),t-=1/(1680*(n*=a)),t+=1/(1188*(n*=a)),t-=691/(360360*(n*=a)),t+=7/(1092*(n*=a)),t-=3617/(122400*(n*=a)),Math.exp(t)/e}(this.sign*this.getOperator(0)));var e=this.getOperator(0)-1,t=.9189385332046727;t+=(e+.5)*Math.log(e);var a=e*e,n=e,i=12*n,o=1/i,l=(t-=e)+o;if(l===t)return r.exp(t);if((l=(t=l)-(o=1/(i=360*(n*=a))))===t)return r.exp(t);t=l;var s=1/(i=1260*(n*=a));return t+=s,t-=s=1/(i=1680*(n*=a)),r.exp(t)}return this.gt(u)?r.exp(this.mul(this.log().sub(1))):r.exp(this)}},{key:"lambertw",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=e;return this.lt(-.3678794411710499)?r.NaN.clone():t?this.abs().lt("1e-300")?new r(this):this.small?r.fromNumber(v(this.toNumber())):this.lt(u)?r.fromNumber(v(this.sign*this.getOperator(0))):this.lt("eee15")?k(this):this.log():-1===this.sign?r.NaN.clone():this.lt(9e15)?r.fromNumber(v(this.sign*this.array[0].repeat,1e-10,!1)):this.lt(r.E_MSI)?k(this,1e-10,!1):this.neg().rec().lambertw().neg()}},{key:"tetrate",value:function(e){var t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.clone(),i=new r(e),o=new r(a);if(n.isNaN()||i.isNaN()||o.isNaN())return r.NaN.clone();if(n.eq(1))return r.ONE.clone();if(o.neq(r.ONE)&&n.gte(c)&&(i=i.add(o.slog(n))),i.isInfi()&&i.sign>0)return n.gte(c)?r.POSITIVE_INFINITY.clone():(t=this.log().neg()).lambertw().div(t);if(i.lte(-2))return r.NaN.clone();if(n.isZero())return i.isZero()?r.NaN.clone():i.gte(u/2)||i.toNumber()%2==0?r.ZERO.clone():r.ONE.clone();if(n.eq(r.ONE))return i.eq(r.ONE.neg())?r.NaN.clone():r.ONE.clone();if(i.eq(r.ONE.neg()))return r.ZERO.clone();if(i.eq(r.ZERO))return r.ONE.clone();if(i.eq(r.ONE))return n;if(i.eq(2))return n.pow(n);if(n.eq(2)){if(i.eq(3))return r.fromNumber(16);if(i.eq(4))return r.fromNumber(65536)}var l=n.max(i);if(l.gt(r.PENTATED_MSI))return l;if(l.gt(r.TETRATED_MSI)||i.gt(u)){if(this.lt(c))return(t=n.ln().neg()).lambertw().div(t);var s=n.slog(10).add(i);return s.setOperator(s.getOperator(2)+1,2),s.normalize(),s}for(var f=i.toNumber(),g=Math.floor(f),h=n.pow(f-g),y=r.NaN,p=0,m=r.E_MSI.clone();0!==g&&h.lt(m)&&p<100;++p)if(g>0){if(h=n.pow(h),y.eq(h)){g=0;break}y=h,--g}else{if(h=h.log(n),y.eq(h)){g=0;break}y=h,++g}return(100==p||this.lt(c))&&(g=0),h.setOperator(h.getOperator(1)+g,1),h.normalize(),h}},{key:"tetr",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.tetrate(r,e)}},{key:"slog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=this.clone(),a=new r(e);if(t.isInfiNaN())return t;if(a.isNaN())return a;if(a.isInfi())return r.ZERO.clone();if(t.isZero())return r.ONE.clone();if(t.eq(r.ONE))return r.ZERO.clone();if(t.eq(a))return r.ONE.clone();if(a.lt(c)){var n=a.tetrate(1/0);if(t.eq(n))return r.POSITIVE_INFINITY.clone();if(t.gt(n))return r.NaN.clone()}if(t.max(a).gt(r.PENTATED_MSI))return t.gt(a)?t:r.ZERO.clone();if(t.max(a).gt(r.TETRATED_MSI)&&t.gt(a))return t.setOperator(t.getOperator(2)-1,2),t.normalize(),t.sub(t.getOperator(1));if(t.lt(r.ZERO.clone()))return a.pow(t).sub(2);var i=0,o=t.getOperator(1)-a.getOperator(1);if(o>3){var u=o-3;i+=u,t.setOperator(t.getOperator(1)-u,1)}for(var l=0;l<100;++l)if(t.lt(r.ZERO))t=r.pow(e,t),--i;else{if(t.lte(1))return new r(i+t.toNumber()-1);++i,t=r.log(t,e)}return t.gt(10)?new r(i):r.NaN.clone()}},{key:"ssqrt",value:function(){var e=this.clone();if(e.lt(1/c))return r.NaN.clone();if(!e.isFinite())return e;if(e.gt(r.TETRATED_MSI))return e;if(e.gt(r.EE_MSI))return e.setOperator(e.getOperator(1)-1,1),e;var t=e.ln();return t.div(t.lambertw())}},{key:"tetrate_10",value:function(){return r.tetrate(10,this)}},{key:"iteratedlog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,a=this.clone(),n=new r(t),i=new r(e);return i.isZero()?a:i.eq(r.ONE)?a.log(n):n.tetrate(a.slog(n).sub(i))}},{key:"arrow",value:function(e){var t=this.clone(),a=new r(e);return!a.isInt()||a.lt(r.ZERO)?(console.warn("The arrow is <0 or not a integer, the returned function will return NaN."),function(){return r.NaN.clone()}):a.eq(0)?function(r){return t.mul(r)}:a.eq(1)?function(r){return t.pow(r)}:a.eq(2)?function(r){return t.tetrate(r)}:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=new r(e),l=new r(n),s=r.arrowFuncMap.get("".concat(t.toString()," ").concat(a.toString()," ").concat(o.toString()," ").concat(i));if(s)return s.clone();var c=function(){var e;if(t.isNaN()||o.isNaN()||l.isNaN())return r.NaN.clone();if(o.lt(r.ZERO))return r.NaN.clone();if(t.eq(r.ZERO))return o.eq(r.ONE)?r.ZERO.clone():r.NaN.clone();if(l.neq(r.ONE)&&(o=o.add(l.anyarrow_log(a)(t))),t.eq(r.ONE))return r.ONE.clone();if(o.eq(r.ZERO))return r.ONE.clone();if(o.eq(r.ONE))return t.clone();if(a.gt(r.MSI))return(e=a.clone()).setOperator(e.getOperator(1/0)+1,1/0),e;var n=a.toNumber();if(o.eq(2))return t.arrow(n-1)(t,l,i+1);if(t.max(o).gt(r.arrowMSI(n+1)))return t.max(o);if(t.gt(r.arrowMSI(n))||o.gt(u)){t.gt(r.arrowMSI(n))?((e=t.clone()).setOperator(e.getOperator(n)-1,n),e.normalize()):e=t.gt(r.arrowMSI(n-1))?new r(t.getOperator(n-1)):r.ZERO;var s=e.add(o);return s.setOperator(s.getOperator(n)+1,n),s.normalize(),s}if(i>=r.maxOps+10)return new r({small:!1,sign:1,layer:0,array:[h(10,0),h(1,n)]});var c=o.toNumber(),f=Math.floor(c),g=a.sub(r.ONE);e=t.arrow(g)(c-f,l,i+1);for(var y=0,p=r.arrowMSI(n-1);0!==f&&e.lt(p)&&y<100;y++)f>0&&(e=t.arrow(g)(e,l,i+1),--f);return 100==y&&(f=0),e.setOperator(e.getOperator(n-1)+f,n-1),e.normalize(),e}();return i<r.maxOps+10&&r.arrowFuncMap.set("".concat(t.toString()," ").concat(a.toString()," ").concat(o.toString()," ").concat(i),c.clone()),c}}},{key:"anyarrow_log",value:function(e){var t=this.clone(),a=new r(e),n=a.toNumber();if(a.gt(u))throw new Error("[PowiainaNum 0.2 error]Not implemented");return!a.isInt()||a.lt(0)?function(){return r.NaN.clone()}:a.eq(0)?function(r){return t.div(r)}:a.eq(1)?function(r){return t.log(r)}:a.eq(2)?function(r){return t.slog(r)}:t.isInfiNaN()?function(){return t}:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=new r(e);if(i.isNaN())return i;if(i.isInfi())return r.ZERO.clone();if(t.isZero())return r.ONE.clone();if(t.eq(r.ONE))return r.ZERO.clone();if(t.eq(i))return r.ONE.clone();if(t.max(i).gt(r.arrowMSI(n+1)))return t.gt(i)?t:r.ZERO.clone();if(t.max(i).gt(r.arrowMSI(n))&&t.gt(i))return t.setOperator(t.getOperator(n)-1,n),t.normalize(),t.sub(t.getOperator(n-1));if(t.lt(r.ZERO.clone()))return r.NaN.clone();var o=0,u=t.getOperator(n)-i.getOperator(n);if(u>3){var l=u-3;o+=l,t.setOperator(t.getOperator(n)-l,n)}for(var s=0;s<100;++s)if(t.lt(r.ZERO))t=t.arrow(n-1)(e),--o;else{if(t.lte(1))return new r(o+t.toNumber()-1);++o,t=t.anyarrow_log(n-1)(e,a+1)}return t.gt(10)?new r(o):r.NaN.clone()}}},{key:"arrow_height_inverse",value:function(r){return this.anyarrow_log(r)}},{key:"chain",value:function(r,e){return this.arrow(e)(r)}},{key:"pentate",value:function(r,e){return this.arrow(3)(r,e)}},{key:"hexate",value:function(r,e){return this.arrow(4)(r,e)}},{key:"pent",value:function(r,e){return this.arrow(3)(r,e)}},{key:"penta_log",value:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return this.anyarrow_log(3)(r)}},{key:"expansion",value:function(e){var t,a=new r(e),n=this.clone();if(a.lt(r.ZERO)||!a.isInt())return r.NaN.clone();if(a.eq(r.ONE))return this.clone();if(this.eq(r.ONE))return r.ONE.clone();if(!this.isInt())return r.NaN.clone();if(this.eq(2))return new r(4);if(a.eq(0))return r.ONE.clone();if(n.gt("10{1,2}".concat(u))||a.gt(u)){n.gt("10{1,2}".concat(u))?((t=n.clone()).setOperator(t.getOperator(1,2)-1,1,2),t.normalize()):t=n.gt("10{".concat(u,"}10"))?new r(n.getOperator(1/0)):r.ZERO;var i=t.add(a);return i.setOperator(i.getOperator(1,2)+1,1,2),i.normalize(),i}var o,l=a.toNumber()-1;for(t=n.clone(),o=0;0!==l&&t.lt(u)&&o<100;++o)l>0&&(t=n.arrow(t)(n),--l);return 100==o&&(l=0),t.setOperator(t.getOperator(1/0)+l,1/0),t.normalize(),t}},{key:"expansionArrow",value:function(e){var t=new r(e),a=this.clone();if(t.lt(0)||!t.isInt()||t.isNaN()||this.isNaN())return function(){return r.NaN.clone()};if(t.eq(0))return function(r){return a.arrow(r)(a)};if(t.eq(1))return function(r){return a.expansion(r)};var n=t;return function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=new r(e);if(a.isNaN()||o.isNaN())return r.NaN.clone();if(o.lt(r.ZERO))return r.NaN.clone();if(a.eq(r.ZERO))return o.eq(r.ONE)?r.ZERO.clone():r.NaN.clone();if(a.eq(r.ONE))return r.ONE.clone();if(o.eq(r.ZERO))return r.ONE.clone();if(o.eq(r.ONE))return a.clone();if(n.gt(r.MSI))return(t=n.clone()).setOperator(t.getOperator(1/0,2)+1,1/0,2),t;var l=n.toNumber();if(o.eq(2))return a.expansionArrow(l-1)(a,i+1);if(a.max(o).gt("10{".concat(l+1,",2}").concat(u)))return a.max(o);if(a.gt("10{".concat(l,",2}").concat(u))||o.gt(u)){a.gt("10{".concat(l,",2}").concat(u))?((t=a.clone()).setOperator(t.getOperator(l,2)-1,l,2),t.normalize()):t=a.gt("10{".concat(l-1,",2}").concat(u))?new r(a.getOperator(l-1,2)):r.ZERO;var s=t.add(o);return s.setOperator(s.getOperator(l,2)+1,l,2),s.normalize(),s}if(i>=r.maxOps+10)return new r({small:!1,sign:1,layer:0,array:[h(10,0),h(1,l,2)]});var c=o.toNumber(),f=Math.floor(c),g=n.sub(r.ONE);t=a.expansionArrow(g)(c-f,i+1);for(var y=0,p=new r("10{".concat(l-1,",2}").concat(u));0!==f&&t.lt(p)&&y<100;y++)f>0&&(t=a.expansionArrow(g)(t,i+1),--f);return 100==y&&(f=0),t.setOperator(t.getOperator(l-1,2)+f,l-1,2),t.normalize(),t}}},{key:"multiExpansion",value:function(r){return this.expansionArrow(2)(r)}},{key:"powerExpansion",value:function(r){return this.expansionArrow(3)(r)}},{key:"explosion",value:function(e){return r.BEAF(this,e,1,3)}},{key:"megotion",value:function(e){return r.BEAF(this,e,1,1,2)}},{key:"powiaination",value:function(e){return r.BEAF(this,e,1,1,1,2)}},{key:"abs",value:function(){var r=this.clone();return r.sign<0&&(r.sign*=-1),r}},{key:"clampMin",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.max.apply(r,[this].concat(t))}},{key:"clampMax",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.min.apply(r,[this].concat(t))}},{key:"clamp",value:function(r,e){return this.max(r).min(e)}},{key:"max",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.max.apply(r,[this].concat(t))}},{key:"min",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.min.apply(r,[this].concat(t))}},{key:"maxabs",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=t.map((function(e){return new r(e).abs()}));return r.max.apply(r,[this.abs()].concat(a(i)))}},{key:"minabs",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=t.map((function(e){return new r(e).abs()}));return r.min.apply(r,[this.abs()].concat(a(i)))}},{key:"cmpabs",value:function(e){var t=new r(e).abs();return this.abs().cmp(t)}},{key:"compare",value:function(e){var t=new r(e);if(this.isNaN()||t.isNaN())return 2;if(this.sign<t.sign)return-1;if(this.sign>t.sign)return 1;var a=-1==this.sign&&-1==t.sign;if(this.small&&!t.small)return-1*(a?-1:1);if(t.small&&!this.small)return 1*(a?-1:1);var n=1;this.small&&t.small&&(n*=-1),a&&(n*=-1);for(var i=0,o=0;this.array.length-1-o>=0&&t.array.length-1-o>=0;o++){var u=this.array[this.array.length-1-o],l=t.array[t.array.length-1-o];if(u.repeat===1/0){i=1;break}if(l.repeat===1/0){i=-1;break}var s=y([u.megota,u.expans,u.arrow,u.repeat],[l.megota,l.expans,l.arrow,l.repeat]);if(1==s){i=1;break}if(-1==s){i=-1;break}}return i*n+1-1}},{key:"cmp",value:function(r){return this.compare(r)}},{key:"eq",value:function(r){return 0===this.cmp(r)}},{key:"neq",value:function(r){return 0!==this.cmp(r)}},{key:"lt",value:function(r){return-1===this.cmp(r)}},{key:"lte",value:function(r){return this.cmp(r)<=0}},{key:"gt",value:function(r){return 1==this.cmp(r)}},{key:"gte",value:function(r){var e=this.cmp(r);return 0==e||1==e}},{key:"equals",value:function(r){return this.eq(r)}},{key:"notEquals",value:function(r){return this.neq(r)}},{key:"eq_tolerance",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-7,a=new r(e);return this.sub(a).lte(this.max(a).mul(t))}},{key:"sin",value:function(){var e=this.clone();if(e.isneg())return e.neg().sin().neg();var t=e.mod(7074237752028440);return r.fromNumber(Math.sin(t.toNumber()))}},{key:"cos",value:function(){return this.sub(Math.PI/2).sin()}},{key:"tan",value:function(){return this.sin().div(this.cos())}},{key:"cot",value:function(){return this.cos().div(this.sin())}},{key:"sec",value:function(){return this.cos().rec()}},{key:"csc",value:function(){return this.sin().rec()}},{key:"neg",value:function(){var r=this.clone();return r.sign*=-1,r.normalize(),r}},{key:"rec",value:function(){var r=this.clone();return r.small=!r.small,r}},{key:"recip",value:function(){return this.rec()}},{key:"reciprocate",value:function(){return this.rec()}},{key:"floor",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?r.ZERO.clone():r.ONE.neg().clone();var e=this.abs();return e.array[0].repeat=Math[1==this.sign?"floor":"ceil"](e.getOperator(0)),e.sign=this.sign,e}},{key:"ceil",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?r.ONE.clone():r.ZERO.clone();var e=this.abs();return e.array[0].repeat=Math[1==this.sign?"ceil":"floor"](e.getOperator(0)),e.sign=this.sign,e}},{key:"round",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?this.rec().lte(2)?r.ONE.clone():r.ZERO.clone():this.abs().rec().lte(2)?r.ZERO.clone():r.ONE.neg().clone();var e=this.abs();return e.array[0].repeat=Math.round(e.array[0].repeat),e.sign=this.sign,e}},{key:"trunc",value:function(){var r=this.clone();return r.gte(0)?r.floor():r.ceil()}},{key:"isNaN",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return isNaN(this.getOperator(0))}))},{key:"isZero",value:function(){return Boolean(this.small&&!isFinite(this.getOperator(0)))}},{key:"isFinite",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return Boolean(this.small||isFinite(this.getOperator(0)))&&!this.isNaN()}))},{key:"isInfi",value:function(){return this.rec().isZero()}},{key:"isInfiNaN",value:function(){return this.isInfi()||this.isNaN()}},{key:"isInt",value:function(){return!!this.isZero()||(!(this.small||!Number.isInteger(this.getOperator(0)))||!!this.abs().gte(u/2))}},{key:"ispos",value:function(){return this.sign>0}},{key:"isneg",value:function(){return this.sign<0}},{key:"getOperatorIndex",value:function(r){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=0;a<this.array.length;a++){var n=y([this.array[a].megota,this.array[a].expans,this.array[a].arrow],[t,e,r]);if(0==n)return a;if(1==n)return a-.5}return this.array.length-.5}},{key:"getOperator",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=this.getOperatorIndex(r,e,t);return this.array[a]?this.array[a].repeat:0}},{key:"setOperator",value:function(r,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=this.getOperatorIndex(e,t,a);return this.array[n]?(this.array[n].repeat=r,!1):(this.array.splice(Math.ceil(n),0,{arrow:e,expans:t,megota:a,valuereplaced:t===1/0?1:e==1/0?0:-1,repeat:r}),!0)}},{key:"toNumber",value:function(){return-1==this.sign?-this.neg().toNumber():this.small?1/this.rec().toNumber():this.array.length>2?1/0:1==this.array.length?this.array[0].repeat:2==this.array.length&&1==this.array[1].arrow&&1==this.array[1].expans&&1==this.array[1].megota&&1==this.array[1].repeat?Math.pow(10,this.getOperator(0)):NaN}},{key:"toString_core",value:function(){if(this.isNaN())return"NaN";if(-1==this.sign)return"-".concat(this.neg().toString());if(this.small)return this.isZero()?"0":"/".concat(this.rec().toString());if(this.isInfi())return"Infinity";var r="";this.layer?this.layer<3?r+="P".repeat(this.layer):r+="P^"+this.layer+" ":r+="";for(var e=this.array.length-1;e>=0;e--){var t=this.array[e],a="10{".concat(t.arrow===1/0?"!":t.arrow).concat(t.expans>1||t.megota>1?",".concat(t.expans===1/0?"!":t.expans):"").concat(t.megota>1?",".concat(t.megota):"","}");a=1==t.arrow&&1==t.expans&&1==t.megota&&t.repeat<5?"e".repeat(t.repeat):0==t.arrow&&1==t.expans&&1==t.megota?t.repeat.toString():t.repeat>1?"(".concat(a,")^").concat(t.repeat," "):"".concat(a),r+="".concat(a)}return r}},{key:"toString",value:function(){try{return this.toString_core()}catch(r){return console.error("Checked error when converting to string"),"NaN"}}},{key:"toJSON",value:function(){return"PN"+this.toString()}},{key:"arr01",get:function(){for(var r=[0],e=0;e<this.array.length;e++)0==e?r[0]=this.array[e].repeat:(r[e]=[0,0,0,0],r[e][0]=this.array[e].arrow==1/0?"x":this.array[e].arrow,r[e][1]=this.array[e].repeat,r[e][2]=this.array[e].expans==1/0?"x":this.array[e].expans,r[e][3]=this.array[e].megota);return r}},{key:"normalize",value:function(){var e=!0,t=this;void 0===this.array&&(t.array=[h(NaN,0,1,1)]),void 0===this.sign&&(this.sign=0),void 0===this.layer&&(this.layer=0);for(var a=0;a<this.array.length;a++)if(this.array[a].repeat==1/0)return this.array=[{arrow:0,expans:1,megota:1,repeat:1/0}],this.layer=0,this;for(var n=1;n<t.array.length;++n){var i=t.array[n];if(null!==i.arrow&&void 0!==i.arrow||(i.arrow=0),null!==i.expans&&void 0!==i.expans||(i.expans=1),null!==i.megota&&void 0!==i.megota||(i.megota=1),isNaN(i.arrow)||isNaN(i.repeat)||isNaN(i.expans)||isNaN(i.megota))return t.array=[h(NaN,0,1,1)],t;if(!isFinite(i.repeat)||!isFinite(i.megota))return t.array=[h(1/0,0,1,1)],t;Number.isInteger(i.arrow)||(i.arrow=Math.floor(i.arrow)),Number.isInteger(i.repeat)||(i.repeat=Math.floor(i.repeat)),Number.isInteger(i.expans)||(i.expans=Math.floor(i.expans)),Number.isInteger(i.megota)||(i.megota=Math.floor(i.megota))}t.array.length||(t.small=!t.small,t.array=[h(1/0)]);do{e=!1,this.array.sort(x);for(var o=1;o<t.array.length-1;++o)t.array[o].arrow==t.array[o+1].arrow&&t.array[o].expans==t.array[o+1].expans&&t.array[o].megota==t.array[o+1].megota&&(t.array[o].repeat+=t.array[o+1].repeat,t.array.splice(o+1,1),--o,e=!0);for(var s=1;s<t.array.length;++s)0===t.array[s].arrow||0!==t.array[s].repeat&&null!==t.array[s].repeat&&void 0!==t.array[s].repeat?0==t.array[s].arrow&&t.array[s].expans>=2&&(t.array[s].arrow=1/0,t.array[s].valuereplaced=0,t.array[s].expans=t.array[s].expans-1):(t.array.splice(s,1),--s);for(t.array.length>r.maxOps&&t.array.splice(1,t.array.length-r.maxOps),this.array.length>=2&&1==this.array[1].arrow&&this.array[1].repeat>=1&&this.array[0].repeat<l&&(this.setOperator(this.array[1].repeat-1,1),this.setOperator(Math.pow(10,this.array[0].repeat),0),e=!0),this.getOperator(0)>u&&isFinite(this.getOperator(0))&&(this.setOperator(this.getOperator(1)+1,1),this.setOperator(Math.log10(this.getOperator(0)),0),e=!0),this.array[this.array.length-1].megota>u?(this.layer++,this.array=[h(this.array[this.array.length-1].megota)],e=!0):this.layer&&1==this.array.length&&0===this.array[0].arrow&&(this.layer--,this.array=[h(10),h(1,10,10,this.array[0].repeat)],e=!0),1==this.array.length&&this.array[0].repeat<1&&(this.array[0].repeat=1/this.array[0].repeat,this.small=!this.small,e=!0),1==this.array.length&&1==this.array[0].repeat&&this.small&&(this.small=!1,e=!0),this.array.length>=2&&this.array[1].arrow>=u&&(this.array[0].repeat=this.array[1].arrow,this.array[1]=h(1,1/0,this.array[1].expans,this.array[1].megota));t.array.length>=2&&1==t.array[0].repeat&&t.array[1].repeat;)t.array[1].repeat>1?t.array[1].repeat--:t.array.splice(1,1),t.array[0].repeat=10,e=!0;t.array.length>=2&&t.array.length<r.maxOps&&t.array[0].repeat<u&&t.array[1].arrow>=2&&t.array[1].repeat>1&&isFinite(t.array[1].arrow)&&(t.array[1].repeat--,t.array.splice(1,0,h(t.array[0].repeat-1,t.array[1].arrow-1,t.array[1].expans,t.array[1].megota)),t.array[0].repeat=10,e=!0),t.array.length>=2&&t.array[0].repeat<u&&t.array[1].arrow>=2&&1==t.array[1].repeat&&isFinite(t.array[1].arrow)&&(t.array.splice(1,1,h(t.array[0].repeat-1,t.array[1].arrow-1,t.array[1].expans,t.array[1].megota)),t.array[0].repeat=10,e=!0),t.array.length>=2&&t.array[1].repeat>u&&t.array[1].arrow!==1/0&&(t.array[1].arrow++,t.array[0].repeat=t.array[1].repeat,t.array[1].repeat=1,e=!0),t.array.length>=2&&t.array[1].repeat>u&&t.array[1].arrow===1/0&&(t.array[1].arrow=1,t.array[1].expans++,t.array[0].repeat=t.array[1].repeat,t.array[1].repeat=1,e=!0)}while(e);return this}},{key:"clone",value:function(){var e=new r;return e.resetFromObject(this),e}},{key:"resetFromObject",value:function(r){if(r.array){this.array=[];for(var e=0;e<r.array.length;e++)this.array[e]={arrow:r.array[e].arrow,expans:r.array[e].expans,megota:r.array[e].megota,repeat:r.array[e].repeat,valuereplaced:r.array[e].valuereplaced};return this.small=r.small,this.sign=r.sign,this.layer=r.layer,this}}}],[{key:"add",value:function(e,t){return new r(e).add(t)}},{key:"plus",value:function(e,t){return new r(e).add(t)}},{key:"sub",value:function(e,t){return new r(e).sub(t)}},{key:"minus",value:function(e,t){return new r(e).sub(t)}},{key:"mul",value:function(e,t){return new r(e).mul(t)}},{key:"times",value:function(e,t){return new r(e).mul(t)}},{key:"div",value:function(e,t){return new r(e).div(t)}},{key:"divide",value:function(e,t){return new r(e).div(t)}},{key:"mod",value:function(e,t){return new r(e).mod(t)}},{key:"modulus",value:function(e,t){return new r(e).mod(t)}},{key:"pow",value:function(e,t){return new r(e).pow(t)}},{key:"root",value:function(e,t){return new r(e).root(t)}},{key:"sqrt",value:function(e){return new r(e).sqrt()}},{key:"cbrt",value:function(e){return new r(e).cbrt()}},{key:"log10",value:function(e){return new r(e).log10()}},{key:"log",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new r(e).log(t)}},{key:"log2",value:function(e){return new r(e).log2()}},{key:"logBase",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new r(e).log(t)}},{key:"pLog10",value:function(e){return new r(e).pLog10()}},{key:"exp",value:function(e){return new r(e).pow_base(Math.E)}},{key:"factorial",value:function(e){return new r(e).factorial()}},{key:"gamma",value:function(e){return new r(e).gamma()}},{key:"lambertw",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new r(e).lambertw(t)}},{key:"affordGeometricSeries",value:function(e,t,a,n){return this.affordGeometricSeries_core(new r(e),new r(t),new r(a),n)}},{key:"affordGeometricSeries_core",value:function(r,e,t,a){var n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],i=e.mul(t.pow(a));return r.div(i).mul(t.sub(1)).add(1).clampMin(n?1:-1/0).log10().div(t.log10()).floor()}},{key:"sumGeometricSeries",value:function(e,t,a,n){return this.sumGeometricSeries_core(e,new r(t),new r(a),n)}},{key:"sumGeometricSeries_core",value:function(e,t,a,n){return t.mul(a.pow(n)).mul(r.sub(1,a.pow(e))).div(r.sub(1,a))}},{key:"affordArithmeticSeries",value:function(e,t,a,n){return this.affordArithmeticSeries_core(new r(e),new r(t),new r(a),new r(n))}},{key:"affordArithmeticSeries_core",value:function(r,e,t,a){var n=e.add(a.mul(t)).sub(t.div(2)),i=n.pow(2);return n.neg().add(i.add(t.mul(r).mul(2)).sqrt()).div(t).floor()}},{key:"sumArithmeticSeries",value:function(e,t,a,n){return this.sumArithmeticSeries_core(new r(e),new r(t),new r(a),new r(n))}},{key:"sumArithmeticSeries_core",value:function(r,e,t,a){var n=e.add(a.mul(t));return r.div(2).mul(n.mul(2).add(r.sub(1).mul(t)))}},{key:"tetrate",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return new r(e).tetrate(t,a)}},{key:"tetrate_10",value:function(e){return r.fromNumber(10).tetrate(e)}},{key:"iteratedlog",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return new r(e).iteratedlog(t,a)}},{key:"arrow",value:function(e,t,a){return new r(e).arrow(t)(a)}},{key:"arrFrac",value:function(e,t){var a=new r(e).clone(),n=new r(t).clone();return new r(a).arrow(n.floor().add(1))(a.div(2).pow(n.sub(n.floor())).mul(2))}},{key:"arrowMSI",value:function(e){return new r("10{".concat(e,"}").concat(u))}},{key:"hyper",value:function(e){var t=new r(e);return t.eq(0)?function(e,t){return new r(t).eq(0)?new r(e):new r(e).add(1)}:t.eq(1)?r.add:t.eq(2)?r.mul:t.eq(3)?r.pow:function(e,a){return new r(e).arrow(t.sub(2))(a)}}},{key:"pentate",value:function(e,t,a){return new r(e).arrow(3)(t,a)}},{key:"hexate",value:function(e,t,a){return new r(e).arrow(4)(t,a)}},{key:"pent",value:function(e,t,a){return new r(e).arrow(3)(t,a)}},{key:"penta_log",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;return new r(e).anyarrow_log(3)(t)}},{key:"expansion",value:function(e,t){return new r(e).expansion(t)}},{key:"multiExpansion",value:function(e,t){return new r(e).multiExpansion(t)}},{key:"powerExpansion",value:function(e,t){return new r(e).powerExpansion(t)}},{key:"BEAF",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];function n(e){return void 0!==t[e]&&null!==t[e]?new r(t[e]):new r(1)}return n(0).eq(1)?new r(1):n(1).eq(1)?new r(n(0)):n(5).eq(2)&&(n(4).gte(2)||n(3).gte(2)||n(2).gte(2))||0!==t.slice(6).map((function(e){return new r(e)})).filter((function(r){return r.gt(1)})).length?r.POSITIVE_INFINITY.clone():r.BEAF_core(n(0),n(1),n(2),n(3),n(4),n(5))}},{key:"BEAF_core",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,c=new r(e),f=new r(t);function g(e){var t;return new r(null!==(t=[n,i,o,l][e])&&void 0!==t?t:1)}if(c.eq(1))return new r(1);if(f.eq(1))return new r(c);if(f.isZero())return new r(1);if(c.lt(0))return r.NaN.clone();if(new r(l).gte(3))return r.POSITIVE_INFINITY.clone();if(g(0).eq(1)&&g(1).eq(1)&&g(2).eq(1))return c.pow(f);if(g(0).eq(2)&&g(1).eq(1)&&g(2).eq(1)&&g(3).eq(1))return c.tetrate(f);if(g(1).eq(1)&&g(2).eq(1)&&g(3).eq(1))return c.arrow(g(0))(f);if(g(1).eq(2)&&g(2).eq(1)&&g(3).eq(1))return c.expansionArrow(g(0))(f);var y=g(0).toNumber(),p=g(1),m=g(2),v=g(3);if(v.eq(2)){if(1!=y)return r.POSITIVE_INFINITY.clone();if(p.neq(1))return r.POSITIVE_INFINITY.clone();if(m.neq(1))return r.POSITIVE_INFINITY.clone();if(f.gte(u))return r.POSITIVE_INFINITY.clone();var N=new r(10);return N.layer=f.toNumber(),N.normalize(),N}function w(r,e,t){return 0==r&&e>1?[1/0,e-1,t]:0==r&&1==e&&t>1?[1,1/0,t-1]:[r,e,t]}if(m.gt(u)){var b=new r(m);return b.layer++,b.normalize(),b}function d(r){return isFinite(r)?r.toString():"!"}function O(r,e,t){return"10{".concat(d(r),",").concat(d(e),",").concat(t,"}").concat(u)}var E=c.clone(),I=new r(g(0)),k=function(s){var g,y,v=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;console.log("".concat("-".repeat(v)," {").concat(e,",").concat(t,",").concat(n,",").concat(i,",").concat(o,"}"));var N,b=new r(s);if(E.isNaN()||b.isNaN())return r.NaN.clone();if(b.lt(r.ZERO))return r.NaN.clone();if(E.eq(r.ZERO))return b.eq(r.ONE)?r.ZERO.clone():r.NaN.clone();if(E.eq(r.ONE))return r.ONE.clone();if(b.eq(r.ZERO))return r.ONE.clone();if(b.eq(r.ONE))return E.clone();if(I.eq(0))return r.BEAF(E,E,f,p.sub(1),m,l,v+1);if(p.eq(0))return r.BEAF(E,E,E,f,m.sub(1),l,v+1);if(m.eq(0))return r.BEAF(E,E,E,E,p,new r(l).sub(1),v+1);if(p.gt(u))return(N=new r(p)).setOperator(N.getOperator(1,1/0,m.toNumber())+1,1,1/0,m.toNumber()),N;if(I.gt(r.MSI))return(N=I.clone()).setOperator(N.getOperator(1/0,p.toNumber(),m.toNumber())+1,1/0,p.toNumber(),m.toNumber()),N;var d=I.toNumber();if(b.eq(2))return r.BEAF(E,E,d-1,p,m,l,v+1);if(E.max(b).gt(O(d+1,p.toNumber(),m.toNumber())))return E.max(b);if(E.gt(O(d,p.toNumber(),m.toNumber()))||b.gt(u)){E.gt(O(d,p.toNumber(),m.toNumber()))?((N=E.clone()).setOperator(N.getOperator(d,p.toNumber(),m.toNumber())-1,d,p.toNumber(),m.toNumber()),N.normalize()):N=E.gt(O.apply(void 0,a(w(d-1,p.toNumber(),m.toNumber()))))?new r(E.getOperator.apply(E,a(w(d-1,p.toNumber(),m.toNumber())))):r.ZERO;var k=N.add(b);return k.setOperator(k.getOperator(d,p.toNumber(),m.toNumber())+1,d,p.toNumber(),m.toNumber()),k.normalize(),k}if(v>=r.maxOps+10)return new r({small:!1,sign:1,layer:0,array:[h(10,0),h(1,d,p.toNumber(),m.toNumber())]});var x=b.toNumber(),M=Math.floor(x),q=I.sub(r.ONE);N=r.BEAF(E,x-M,q.toNumber(),p,m,l,v+1);for(var S=0,T=new r(O.apply(void 0,a(w(d-1,p.toNumber(),m.toNumber()))));0!==M&&N.lt(T)&&S<100;S++)M>0&&(N=r.BEAF(c,N,q.toNumber(),p,m,l,v+1),--M);return 100==S&&(M=0),(g=N).setOperator.apply(g,[(y=N).getOperator.apply(y,a(w(d-1,p.toNumber(),m.toNumber())))+M].concat(a(w(d-1,p.toNumber(),m.toNumber())))),N.normalize(),N}(f,s);return console.log("".concat("-".repeat(s)," = ").concat(k)),k}},{key:"abs",value:function(e){return new r(e).abs()}},{key:"max",value:function(){for(var e=r.NEGATIVE_INFINITY,t=arguments.length,a=new Array(t),n=0;n<t;n++)a[n]=arguments[n];for(var i=0;i<a.length;i++)e.lt(a[i])&&(e=new r(a[i]).clone());return e}},{key:"min",value:function(){for(var e=r.POSITIVE_INFINITY,t=arguments.length,a=new Array(t),n=0;n<t;n++)a[n]=arguments[n];for(var i=0;i<a.length;i++)e.gt(a[i])&&(e=new r(a[i]).clone());return e}},{key:"clampMin",value:function(){return r.max.apply(r,arguments)}},{key:"clampMax",value:function(){return r.min.apply(r,arguments)}},{key:"eq",value:function(e,t){return new r(e).eq(t)}},{key:"equals",value:function(e,t){return new r(e).eq(t)}},{key:"neq",value:function(e,t){return new r(e).neq(t)}},{key:"notEquals",value:function(e,t){return new r(e).notEquals(t)}},{key:"lt",value:function(e,t){return new r(e).lt(t)}},{key:"gt",value:function(e,t){return new r(e).gt(t)}},{key:"lte",value:function(e,t){return new r(e).lte(t)}},{key:"gte",value:function(e,t){return new r(e).gte(t)}},{key:"rec",value:function(e){return new r(e).rec()}},{key:"recip",value:function(e){return new r(e).rec()}},{key:"reciprocate",value:function(e){return new r(e).rec()}},{key:"floor",value:function(e){return new r(e).floor()}},{key:"ceil",value:function(e){return new r(e).ceil()}},{key:"round",value:function(e){return new r(e).round()}},{key:"trunc",value:function(e){return new r(e).trunc()}},{key:"sign",value:function(e){return new r(e).sign}},{key:"isNaN",value:function(e){return new r(e).isNaN()}},{key:"fromNumber",value:function(e){var t=new r;if(t.resetFromObject({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),e<0)t.sign=-1;else{if(0==e)return t.sign=0,t.small=!0,t.array=[h(1/0,0)],t;e>0&&(t.sign=1)}var a=Math.abs(e);return a==1/0?t.array=[h(1/0,0)]:a>=s&&a<1?(t.small=!0,t.array=[h(1/a,0)]):a<s?(t.small=!0,t.array=[h(-Math.log10(a),0),h(1,1)]):a<=u?t.array=[h(a,0)]:(t.setOperator(Math.log10(a),0),t.array=[h(Math.log10(a),0),h(1,1)]),t}},{key:"fromString",value:function(e){if(r.usingBreakEternityLikeFromString&&g.test(e)){var t=e.match(/(e+-)(\d+(.\d+)?)/);if(t){var a=t[1].length;e="e-"+"e".repeat(a-1)+t[2]}}return this.fromString_core(e)}},{key:"fromString_core",value:function(e){var t,a,n,i,o,s,c,g=new r(NaN);if(e.startsWith("PN")&&(e=e.substring(2)),"NaN"==e)return r.NaN.clone();if(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/J\^(\d+)/g,"(10{!})^$1")).replace(/J/g,"10{!}")).replace(/K\^(\d+)/g,"(10{1,2})^$1")).replace(/K/g,"10{1,2}")).replace(/L\^(\d+)/g,"(10{2,2})^$1")).replace(/L/g,"10{2,2}")).replace(/M\^(\d+)/g,"(10{!,2})^$1")).replace(/M/g,"10{!,2}")).replace(/N\^(\d+)/g,"(10{1,!})^$1")).replace(/N/g,"10{1,!}"),/^.*e-.*(e|\^).*/.test(e)&&(e="/10^"+e.substring(e.indexOf("e-"))),!isNaN(Number(e))){var y=Number(e),m=!1;if(0==y?/^((0)|(0*\.0+e\d+)|(0*\.0*))$/.test(e)&&(m=!0):m=!0,!m){var v=e.search(/e/),N=e.substring((-1==v?e.length:v)+1),w=e.substring(0,-1==v?void 0:v),b=[0,0];if(b[1]=Number(N||"0"),Number(w)>=1){var d=w.length>=17?p(w):Math.log10(Number(w)),O=Math.floor(d),E=d-O;b[0]=Math.pow(10,E),b[1]+=O}else{var I=(c=w.match(/^0\.(0*)[1-9]/))?c[1].length:0;w=(w=w.substring(w.search(/[1-9]/))).charAt(0)+"."+w.substring(1),I+=1,b[0]=Number(w),b[1]+=-I}return r.pow(10,-b[1]-1).mul(10*Math.pow(b[0],-1)).rec()}if(isFinite(y)&&m)return g=r.fromNumber(Number(e))}if(-1!==e.indexOf("l")&&-1!==e.indexOf("s")&&-1!==e.indexOf("a")){var k=function(r){var e=r.match(/l(\d+)\s+s(\d+)\s+a(\[.*\])/);try{if(e)return{lValue:parseInt(e[1]),sValue:parseInt(e[2]),array:JSON.parse(e[3])}}catch(r){return null}return null}(e);if(!k||0!==k.sValue&&1!==k.sValue&&-1!==k.sValue)throw"[PowiainaNum 0.2 error]malformed input: "+e;return(g=r.fromObject(k.array)).layer=k.lValue,g.sign=k.sValue,g.small=!1,g.normalize(),g}if(e=function(r){for(var e="",t=!1,a=0;a<r.length;a++){var n=r[a];"{"===n?(t=!0,e+=n):"}"===n?(t=!1,e+=n):","===n?t&&(e+=n):e+=n}return e}(e=e.replace(/\(e\^(\d+)\)/g,"(10^)^$1 ").replace(/(\d+)[Pp][Tt]/g,"(10^)^$1 ")),!f.test(e))throw"[PowiainaNum 0.2 error]malformed input: "+e;var x=!1,M=!1;if("-"==e[0]||"+"==e[0]){var q=e.search(/[^-\+]/);x=(null!==(a=null===(t=e.substring(0,q).match(/-/g))||void 0===t?void 0:t.length)&&void 0!==a?a:0)%2==1,e=e.substring(q)}if("/"==e[0]){var S=e.search(/[^\/]/);M=(null!==(i=null===(n=e.substring(0,S).match(/\//g))||void 0===n?void 0:n.length)&&void 0!==i?i:0)%2==1,e=e.substring(S)}if("NaN"==e)g.array=[h(NaN)];else if("Infinity"==e)g.array=[h(1/0)];else{var T,_,F,A;for(g.sign=1,g.array=[h(0)],"P"==e[0]&&("^"==e[1]?(T=e.substring(2).search(/[^0-9]/)+2,g.layer=Number(e.substring(2,T)),e=e.substring(T+1)):(T=e.search(/[^P]/),g.layer=T,e=e.substring(T)));e&&/^(\(?10[\^\{])/.test(e);){var Z=void 0,R=void 0,P=void 0;if("("==e[0]&&(e=e.substring(1)),"^"==e[2])Z=T=e.substring(2).search(/[^\^]/),_=T+2;else{T=e.indexOf("}");var V=e.substring(3,T).split(",");Z=Number("!"==V[0]?1/0:V[0]),R=Number(null!==(o="!"==V[1]?1/0:V[1])&&void 0!==o?o:1),P=Number(null!==(s=V[2])&&void 0!==s?s:1),_=T+1}")"==(e=e.substring(_))[0]?(T=e.indexOf(" "),F=Number(e.substring(2,T)),e=e.substring(T+1)):F=1,1==Z&&1==R&&1==P?g.array.length>=2&&1==g.array[1].arrow?g.array[1].repeat+=F:g.array.splice(1,0,h(F,1,R,P)):2==Z&&1==R&&1==P?(T=g.array.length>=2&&1==g.array[1].arrow?g.array[1].repeat:0,(_=g.array[0].repeat)>=1e10&&++T,_>=10&&++T,g.array[0].repeat=T,g.array.length>=2&&1==g.array[1].arrow&&g.array.splice(1,1),A=g.getOperatorIndex(2),Number.isInteger(A)?g.array[A].repeat+=F:g.array.splice(Math.ceil(A),0,h(F,2,R,P))):isFinite(Z)?(T=g.getOperator(Z-1),(_=g.getOperator(Z-2))>=10&&++T,A=g.getOperatorIndex(Z),g.array.splice(1,Math.ceil(A)-1),g.array[0].repeat=T,Number.isInteger(A)?g.array[1].repeat+=F:g.array.splice(1,0,h(F,Z,R,P))):g.array.splice(1,0,h(F,Z,R,P))}T=e.split(/[Ee]/),_=[g.array[0].repeat,0],F=1;for(var Y=T.length-1;Y>=0;--Y){_[0]<l&&0===_[1]?_[0]=Math.pow(10,F*_[0]):-1==F?(0===_[1]?_[0]=Math.pow(10,F*_[0]):1==_[1]&&_[0]<=Math.log10(Number.MAX_VALUE)?_[0]=Math.pow(10,F*Math.pow(10,_[0])):_[0]=0,_[1]=0):_[1]++;var z=T[Y].indexOf("."),G=-1==z?T[Y].length:z;0===_[1]?G>=17?(_[0]=Math.log10(_[0])+p(T[Y].substring(0,G)),_[1]=1):T[Y]&&(_[0]*=Number(T[Y])):(A=G>=17?p(T[Y].substring(0,G)):T[Y]?Math.log10(Number(T[Y])):0,1==_[1]?_[0]+=A:2==_[1]&&_[0]<l+Math.log10(A)&&(_[0]+=Math.log10(1+Math.pow(10,Math.log10(A)-_[0])))),_[0]<l&&_[1]?(_[0]=Math.pow(10,_[0]),_[1]--):_[0]>u&&(_[0]=Math.log10(_[0]),_[1]++)}g.array[0].repeat=_[0],_[1]&&(g.array.length>=2&&1==g.array[1].arrow&&1==g.array[1].expans&&1==g.array[1].megota?g.array[1].repeat+=_[1]:g.array.splice(1,0,h(_[1],1,1,1)))}return x&&(g.sign*=-1),M&&(g.small=!g.small),g.normalize(),g.normalize(),g}},{key:"fromObject",value:function(e){var t=new r;if(t.resetFromObject({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),t.array=[],function(r){if(!Array.isArray(r))return!1;for(var e=0;e<r.length;e++){var t=r[e];if(!Array.isArray(t))return!1;if(!N(t))return!1;if(!w(t))return!1}return!0}(e)){for(var a=0;a<e.length;a++)t.array[a]={arrow:e[a][0],expans:1,megota:1,repeat:e[a][1]};return t.small=!1,t.sign=1,t.layer=0,t}if(function(r){if(!Array.isArray(r))return!1;if("number"!=typeof r[0])return!1;for(var e=1;e<r.length;e++){var t=r[e];if(!Array.isArray(t))return!1;if(!d(t))return!1;if(!O(t)&&!E(t)&&!I(t))return!1}return!0}(e)){var n=e;t.array[0]=h(n[0]);for(var i=1;i<n.length;i++){var o=n[i];t.array[1]=h(o[1],b(o[0]),b(o[2]),o[3])}return t.small=!1,t.sign=1,t.layer=0,t}return t.resetFromObject(e),t}},{key:"grahalFunction",value:function(e){var t=new r(e);return!t.isInt()||t.lt(0)||t.isNaN()?r.NaN.clone():t.eq(1)?new r("10^^^(10^)^7625597484984 3638334640023.7783"):t.lte(u)?new r("(10{!})^".concat(t.toNumber()," 10^^^(10^)^7625597484984 3638334640023.7783")):r.BEAF(3,t,1,2)}}])}();o=Symbol.toStringTag,q.ZERO=new q({array:[{arrow:0,expans:1,megota:1,repeat:1/0}],small:!0,layer:0,sign:0}),q.ONE=new q({array:[{arrow:0,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),q.MSI=new q(u),q.MSI_REC=((M=new q(u)).small=!0,M),q.E_MSI=new q({array:[{arrow:0,expans:1,megota:1,repeat:u},{arrow:1,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),q.EE_MSI=new q({array:[{arrow:0,expans:1,megota:1,repeat:u},{arrow:1,expans:1,megota:1,repeat:2}],small:!1,layer:0,sign:1}),q.E_MSI_REC=new q({array:[{arrow:0,expans:1,megota:1,repeat:u},{arrow:1,expans:1,megota:1,repeat:1}],small:!0,layer:0,sign:1}),q.TETRATED_MSI=new q({array:[{arrow:0,expans:1,megota:1,repeat:1e10},{arrow:1,expans:1,megota:1,repeat:u-2}],small:!1,layer:0,sign:1}),q.PENTATED_MSI=new q({array:[{arrow:0,expans:1,megota:1,repeat:10},{arrow:2,expans:1,megota:1,repeat:u-1}],small:!1,layer:0,sign:1}),q.TRITRI=new q({small:!1,layer:0,sign:1,array:[h(3638334640023.7783,0,1,1),h(7625587484984,1,1,1)]}),q.GRAHAMS_NUMBER=new q("(10{!})^63 10^^^(10^)^7625597484984 3638334640023.7783"),q.POSITIVE_INFINITY=new q(1/0),q.NEGATIVE_INFINITY=new q(-1/0),q.NaN=new q({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),q.E=new q(Math.E),q.LN2=new q(Math.LN2),q.LN10=new q(Math.LN10),q.LOG2E=new q(Math.LOG2E),q.LOG10E=new q(Math.LOG10E),q.PI=new q(Math.PI),q.SQRT1_2=new q(Math.SQRT1_2),q.SQRT2=new q(Math.SQRT2),q.maxOps=100,q.POW_2_44_MOD_PI=1.701173079953,q.arrowFuncMap=new Map,q.usingBreakEternityLikeFromString=!1,q.blankArgumentConstructorReturnZero=!1,r.arraySortFunction=x,r.default=q,r.mergeSameArrays=function(r){for(var e=1;e<r.array.length-1;++e)r.array[e].arrow==r.array[e+1].arrow&&r.array[e].expans==r.array[e+1].expans&&r.array[e].megota==r.array[e+1].megota&&(r.array[e].repeat+=r.array[e+1].repeat,r.array.splice(e+1,1),--e)},Object.defineProperty(r,"__esModule",{value:!0})}));
1
+ !function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).PowiainaNum={})}(this,(function(r){"use strict";function e(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,a=Array(e);t<e;t++)a[t]=r[t];return a}function t(r,e){for(var t=0;t<e.length;t++){var a=e[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(r,n(a.key),a)}}function a(r){return function(r){if(Array.isArray(r))return e(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||function(r,t){if(r){if("string"==typeof r)return e(r,t);var a={}.toString.call(r).slice(8,-1);return"Object"===a&&r.constructor&&(a=r.constructor.name),"Map"===a||"Set"===a?Array.from(r):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(r,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(r){var e=function(r,e){if("object"!=typeof r||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var a=t.call(r,e||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==typeof e?e:e+""}function o(r){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var i,u=9007199254740991,l=15.954589770191003,s=11102230246251568e-32,c=1.444667861009766,f=/^(PN)?[\/\-\+]*(Infinity|NaN|(P+|P\^\d+ )?(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})|\(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})\)\^[1-9]\d*\x20*)*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/,h=/^((\d+(\.\d*)?|\d*\.\d+)?([EeFf]([-\+]?)))*(0|\d+(\.\d*)?|\d*\.\d+)$/;function g(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{repeat:r,arrow:e,expans:t,megota:a,valuereplaced:e==1/0?0:t==1/0?1:-1}}function y(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];for(var a=0;a<Math.min(e[0].length,e[1].length);a++){var n=e[0][a],o=e[1][a];if(n<o)return-1;if(n>o)return 1}return 0}function N(r){return Math.log10(Number(r.substring(0,17)))+(r.length-17)}var p=.5671432904097838;function m(r){var e,t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=a,i=n;if(!Number.isFinite(r))return r;if(i){if(0===r)return r;if(1===r)return p;e=r<10?0:Math.log(r)-Math.log(Math.log(r))}else{if(0===r)return-1/0;e=r<=-.1?-2:Math.log(-r)-Math.log(-Math.log(-r))}for(var u=0;u<100;++u){if(t=(r*Math.exp(-e)+e*e)/(e+1),Math.abs(t-e)<o*Math.abs(t))return t;e=t}throw Error("Iteration failed to converge: ".concat(r.toString()))}function v(r){return 2==r.length}function w(r){return"number"==typeof r[0]&&"number"==typeof r[1]}function b(r){return"x"===r?1/0:r}function E(r){return 4==r.length}function d(r){return"number"==typeof r[0]&&"number"==typeof r[1]&&"number"==typeof r[2]&&"number"==typeof r[3]}function O(r){return"x"===r[0]&&"number"==typeof r[1]&&"number"==typeof r[2]&&"number"==typeof r[3]}function I(r){return"number"==typeof r[0]&&"number"==typeof r[1]&&"x"==r[2]&&"number"==typeof r[3]}function k(r){var e,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e10,a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!(r=new q(r)).isFinite())return r;if(a){if(r.eq(q.ZERO))return r;if(r.eq(q.ONE))return new q(p);e=q.log(r)}else{if(r.eq(q.ZERO))return q.NEGATIVE_INFINITY.clone();e=q.log(r.neg())}for(var n=0;n<100;++n){var o=e.neg().exp(),i=e.sub(r.mul(o)),u=e.add(q.ONE).sub(e.add(2).mul(i).div(q.mul(2,e).add(2)));if(u.eq(q.ZERO))return e;var l=e.sub(i.div(u));if(q.abs(l.sub(e)).lt(q.abs(l).mul(t)))return l;e=l}throw Error("Iteration failed to converge: "+r)}function x(r,e){return y([r.megota,r.expans,r.arrow],[e.megota,e.expans,e.arrow])}var M,q=function(){function r(e){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),this[i]="PowiainaNum",this.array=[{arrow:0,expans:1,megota:1,repeat:NaN}],this.small=!1,this.sign=0,this.layer=0,r.blankArgumentConstructorReturnZero&&this.resetFromObject(r.ZERO);try{if(void 0===e);else if("number"==typeof e){var t=r.fromNumber(e);this.resetFromObject(t)}else if("object"==o(e)){var a=r.fromObject(e);this.resetFromObject(a)}else if("string"==typeof e){var n=r.fromString(e);this.resetFromObject(n)}else;}catch(e){if(console.error("Malformed input"),console.error(e),r.throwErrorOnResultNaN&&r.isNaN(this))throw new Error("NaN")}}return function(r,e,a){return e&&t(r.prototype,e),a&&t(r,a),Object.defineProperty(r,"prototype",{writable:!1}),r}(r,[{key:"add",value:function(e){var t,a,n,o,i,c,f=this.clone().normalize(),h=new r(e);if(f.eq(r.POSITIVE_INFINITY)&&h.eq(r.NEGATIVE_INFINITY)||f.eq(r.NEGATIVE_INFINITY)&&h.eq(r.POSITIVE_INFINITY)){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(!f.isFinite())return f.clone();if(!h.isFinite())return h.clone();if(f.isZero())return h.clone();if(h.isZero())return f.clone();if(f.sign==-h.sign&&function(){var r=f.abs(),e=h.abs();return r.eq(e)}())return r.ZERO.clone();if(f.abs().lt(u)&&h.abs().lt(u)&&f.abs().gte(s)&&h.abs().gte(s))return r.fromNumber(f.toNumber()+h.toNumber());if(f.abs().lt(r.E_MSI_REC)||f.abs().gt(r.E_MSI)||h.abs().lt(r.E_MSI_REC)||h.abs().gt(r.E_MSI)){var y=f.maxabs(h);return f.abs().eq(y)?f:(h.abs().eq(y),h)}if(-1==f.sign)return f.neg().add(h.neg()).neg();f.cmpabs(h)>0?(i=f,c=h):(c=f,i=h);var N=i.toNumber()+c.toNumber();if(isFinite(N)&&0!==N)return r.fromNumber(N);var p=1;if(!(i.small||c.small||(null===(t=i.array[1])||void 0===t?void 0:t.repeat)||(null===(a=c.array[1])||void 0===a?void 0:a.repeat)||i.sign!=c.sign))return new r((i.array[0].repeat+c.array[0].repeat)*i.sign);var m=(i.small?-1:1)*((null===(n=i.array[1])||void 0===n?void 0:n.repeat)?i.array[0].repeat:Math.log10(i.array[0].repeat)),v=(c.small?-1:1)*((null===(o=c.array[1])||void 0===o?void 0:o.repeat)?c.array[0].repeat:Math.log10(c.array[0].repeat));if(m-v>l)return i;var w=-Math.floor(m),b=0,E=i.sign*Math.pow(10,m+w)+c.sign*Math.pow(10,v+w);if(E>0&&(b=Math.log10(E)-w),E<0&&(b=Math.log10(-E)-w,p*=-1),0==E)return r.ZERO.clone();var d=r.NaN.clone();return d.sign=1,d.array=b>l||b<-l?[g(b,0),g(1,1)]:[g(Math.pow(10,Math.abs(b)),0)],d.small=b<0,d.sign*=p,d}},{key:"plus",value:function(r){return this.add(r)}},{key:"sub",value:function(e){return this.add(new r(e).neg())}},{key:"minus",value:function(r){return this.sub(r)}},{key:"mul",value:function(e){var t=this.clone(),a=new r(e);if(t.eq(r.POSITIVE_INFINITY)&&a.eq(r.NEGATIVE_INFINITY)||a.eq(r.POSITIVE_INFINITY)&&t.eq(r.NEGATIVE_INFINITY))return r.NEGATIVE_INFINITY.clone();if(t.isInfiNaN()&&a.isZero()||a.isInfiNaN()&&t.isZero()){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(t.eq(r.NEGATIVE_INFINITY)&&a.eq(r.NEGATIVE_INFINITY))return r.POSITIVE_INFINITY.clone();if(!t.isFinite())return t.clone();if(!a.isFinite())return a.clone();if(t.isZero()||a.isZero())return r.ZERO.clone();var n,o=t.toNumber()*a.toNumber();return isFinite(o)&&0!==o?r.fromNumber(o):((n=t.abs().log10().add(a.abs().log10()).pow10()).sign=t.sign*a.sign,n)}},{key:"times",value:function(r){return this.mul(r)}},{key:"div",value:function(e){var t=new r(e).rec();return this.mul(t)}},{key:"divide",value:function(r){return this.div(r)}},{key:"mod",value:function(e){var t=new r(e),a=this.div(t);return a.sub(a.floor()).mul(t)}},{key:"modulus",value:function(r){return this.mod(r)}},{key:"pow10",value:function(){var e,t,a=this.clone();return this.isFinite()?a.isneg()?(a.sign*=-1,a.pow10().rec()):a.lte(308.25471555991675)?r.fromNumber(Math.pow(10,a.toNumber())):a.small?a.lt(r.MSI_REC)?r.ONE:new r(Math.pow(10,Math.pow(a.array[0].repeat,-1))):(a.gt(r.TETRATED_MSI)||(a.setOperator((null!==(t=null===(e=a.array[1])||void 0===e?void 0:e.repeat)&&void 0!==t?t:0)+1,1),a.normalize()),a):this.clone()}},{key:"pow",value:function(e){var t=new r(e);if(this.eq(1))return r.ONE.clone();if(!t.isFinite())return t.clone();if(!this.isFinite())return this.clone();if(this.eq(10))return t.pow10();if(t.isneg())return this.pow(t.neg()).rec();if(this.isneg()){if(!t.isInt()){if(t.small&&t.rec().div(2).eq(1))return this.neg().pow(t).neg();if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}var a=this.abs().pow(t);return a.sign=function(){var r=t.mod(2).round();return r.eq(0)||r.eq(2)?1:-1}(),a}var n=this.toNumber(),o=t.toNumber(),i=Math.pow(n,o);if(isFinite(i)&&0!==i)return r.fromNumber(i);if(this.isZero()&&t.isZero())return r.ONE.clone();if(this.isZero())return r.ZERO.clone();if(t.isZero())return r.ONE.clone();if(this.gt(0))return this.log10().mul(t).pow10();if(t.rec().mod(2).eq(1))return this.neg().log10().mul(t).pow10().neg();if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}},{key:"pow_base",value:function(e){return new r(e).pow(this)}},{key:"root",value:function(e){var t=new r(e);return this.pow(t.rec())}},{key:"sqrt",value:function(){return this.pow(.5)}},{key:"cbrt",value:function(){return this.abs().root(3).mul(this.sign)}},{key:"log10",value:function(){if(this.isneg()){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(this.isZero())return r.NEGATIVE_INFINITY.clone();if(this.small){var e=this.clone();return e.small=!e.small,e.log10().neg()}if(1==this.array.length)return new r(Math.log10(this.array[0].repeat));if(this.gte(r.TETRATED_MSI))return this.clone();var t=this.clone();return t.array[1].repeat=t.array[1].repeat-1,t.normalize(),t}},{key:"log",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.E,t=new r(e);return this.log10().div(t.log10())}},{key:"log2",value:function(){return this.log(2)}},{key:"logBase",value:function(r){return this.log(r)}},{key:"ln",value:function(){return this.log()}},{key:"pLog10",value:function(){return this.isneg()?r.ZERO:this.log10()}},{key:"exp",value:function(){return this.pow_base(Math.E)}},{key:"factorial",value:function(){return this.abs().lt(u)?this.add(1).gamma():this.abs().lt(r.E_MSI)?r.exp(this.mul(this.log10().sub(1))):r.exp(this)}},{key:"gamma",value:function(){if(this.small)return this.rec();if(this.lte(u)){if(this.lt(24))return r.fromNumber(function(r){if(!isFinite(r))return r;if(r<-50)return r===Math.trunc(r)?Number.NEGATIVE_INFINITY:0;for(var e=1;r<10;)e*=r,++r;var t=.9189385332046727;t+=((r-=1)+.5)*Math.log(r),t-=r;var a=r*r,n=r;return t+=1/(12*n),t-=1/(360*(n*=a)),t+=1/(1260*(n*=a)),t-=1/(1680*(n*=a)),t+=1/(1188*(n*=a)),t-=691/(360360*(n*=a)),t+=7/(1092*(n*=a)),t-=3617/(122400*(n*=a)),Math.exp(t)/e}(this.sign*this.getOperator(0)));var e=this.getOperator(0)-1,t=.9189385332046727;t+=(e+.5)*Math.log(e);var a=e*e,n=e,o=12*n,i=1/o,l=(t-=e)+i;if(l===t)return r.exp(t);if((l=(t=l)-(i=1/(o=360*(n*=a))))===t)return r.exp(t);t=l;var s=1/(o=1260*(n*=a));return t+=s,t-=s=1/(o=1680*(n*=a)),r.exp(t)}return this.gt(u)?r.exp(this.mul(this.log().sub(1))):r.exp(this)}},{key:"lambertw",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=e;if(this.lt(-.3678794411710499)){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(t)return this.abs().lt("1e-300")?new r(this):this.small?r.fromNumber(m(this.toNumber())):this.lt(u)?r.fromNumber(m(this.sign*this.getOperator(0))):this.lt("eee15")?k(this):this.log();if(-1===this.sign){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}return this.lt(9e15)?r.fromNumber(m(this.sign*this.array[0].repeat,1e-10,!1)):this.lt(r.E_MSI)?k(this,1e-10,!1):this.neg().rec().lambertw().neg()}},{key:"tetrate",value:function(e){var t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.clone(),o=new r(e),i=new r(a);if(n.isNaN()||o.isNaN()||i.isNaN()){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(n.eq(1))return r.ONE.clone();if(i.neq(r.ONE)&&n.gte(c)&&(o=o.add(i.slog(n))),o.isInfi()&&o.sign>0)return n.gte(c)?r.POSITIVE_INFINITY.clone():(t=this.log().neg()).lambertw().div(t);if(o.lte(-2)){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(n.isZero()){if(o.isZero()){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}return o.gte(u/2)||o.toNumber()%2==0?r.ZERO.clone():r.ONE.clone()}if(n.eq(r.ONE)){if(o.eq(r.ONE.neg())){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}return r.ONE.clone()}if(o.eq(r.ONE.neg()))return r.ZERO.clone();if(o.eq(r.ZERO))return r.ONE.clone();if(o.eq(r.ONE))return n;if(o.eq(2))return n.pow(n);if(n.eq(2)){if(o.eq(3))return r.fromNumber(16);if(o.eq(4))return r.fromNumber(65536)}var l=n.max(o);if(l.gt(r.PENTATED_MSI))return l;if(l.gt(r.TETRATED_MSI)||o.gt(u)){if(this.lt(c))return(t=n.ln().neg()).lambertw().div(t);var s=n.slog(10).add(o);return s.setOperator(s.getOperator(2)+1,2),s.normalize(),s}for(var f=o.toNumber(),h=Math.floor(f),g=n.pow(f-h),y=r.NaN,N=0,p=r.E_MSI.clone();0!==h&&g.lt(p)&&N<100;++N)if(h>0){if(g=n.pow(g),y.eq(g)){h=0;break}y=g,--h}else{if(g=g.log(n),y.eq(g)){h=0;break}y=g,++h}return(100==N||this.lt(c))&&(h=0),g.setOperator(g.getOperator(1)+h,1),g.normalize(),g}},{key:"tetr",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.tetrate(r,e)}},{key:"slog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=this.clone(),a=new r(e);if(t.isInfiNaN())return t;if(a.isNaN())return a;if(a.isInfi())return r.ZERO.clone();if(t.isZero())return r.ONE.clone();if(t.eq(r.ONE))return r.ZERO.clone();if(t.eq(a))return r.ONE.clone();if(a.lt(c)){var n=a.tetrate(1/0);if(t.eq(n))return r.POSITIVE_INFINITY.clone();if(t.gt(n)){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}}if(t.max(a).gt(r.PENTATED_MSI))return t.gt(a)?t:r.ZERO.clone();if(t.max(a).gt(r.TETRATED_MSI)&&t.gt(a))return t.setOperator(t.getOperator(2)-1,2),t.normalize(),t.sub(t.getOperator(1));if(t.lt(r.ZERO.clone()))return a.pow(t).sub(2);var o=0,i=t.getOperator(1)-a.getOperator(1);if(i>3){var u=i-3;o+=u,t.setOperator(t.getOperator(1)-u,1)}for(var l=0;l<100;++l)if(t.lt(r.ZERO))t=r.pow(e,t),--o;else{if(t.lte(1))return new r(o+t.toNumber()-1);++o,t=r.log(t,e)}if(t.gt(10))return new r(o);if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}},{key:"ssqrt",value:function(){var e=this.clone();if(e.lt(1/c)){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(!e.isFinite())return e;if(e.gt(r.TETRATED_MSI))return e;if(e.gt(r.EE_MSI))return e.setOperator(e.getOperator(1)-1,1),e;var t=e.ln();return t.div(t.lambertw())}},{key:"tetrate_10",value:function(){return r.tetrate(10,this)}},{key:"iteratedlog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,a=this.clone(),n=new r(t),o=new r(e);return o.isZero()?a:o.eq(r.ONE)?a.log(n):n.tetrate(a.slog(n).sub(o))}},{key:"arrow",value:function(e){var t=this.clone(),a=new r(e);return!a.isInt()||a.lt(r.ZERO)?(console.warn("The arrow is <0 or not a integer, the returned function will return NaN."),function(){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}):a.eq(0)?function(r){return t.mul(r)}:a.eq(1)?function(r){return t.pow(r)}:a.eq(2)?function(r){return t.tetrate(r)}:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=new r(e),l=new r(n),s=r.arrowFuncMap.get("".concat(t.toString()," ").concat(a.toString()," ").concat(i.toString()," ").concat(o));if(s)return s.clone();var c=function(){var e;if(t.isNaN()||i.isNaN()||l.isNaN())return r.NaN.clone();if(i.lt(r.ZERO))return r.NaN.clone();if(t.eq(r.ZERO)){if(i.eq(r.ONE))return r.ZERO.clone();if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(l.neq(r.ONE)&&(i=i.add(l.anyarrow_log(a)(t))),t.eq(r.ONE))return r.ONE.clone();if(i.eq(r.ZERO))return r.ONE.clone();if(i.eq(r.ONE))return t.clone();if(a.gt(r.MSI))return(e=a.clone()).setOperator(e.getOperator(1/0)+1,1/0),e;var n=a.toNumber();if(i.eq(2))return t.arrow(n-1)(t,l,o+1);if(t.max(i).gt(r.arrowMSI(n+1)))return t.max(i);if(t.gt(r.arrowMSI(n))||i.gt(u)){t.gt(r.arrowMSI(n))?((e=t.clone()).setOperator(e.getOperator(n)-1,n),e.normalize()):e=t.gt(r.arrowMSI(n-1))?new r(t.getOperator(n-1)):r.ZERO;var s=e.add(i);return s.setOperator(s.getOperator(n)+1,n),s.normalize(),s}if(o>=r.maxOps+10)return new r({small:!1,sign:1,layer:0,array:[g(10,0),g(1,n)]});var c=i.toNumber(),f=Math.floor(c),h=a.sub(r.ONE);e=t.arrow(h)(c-f,l,o+1);for(var y=0,N=r.arrowMSI(n-1);0!==f&&e.lt(N)&&y<100;y++)f>0&&(e=t.arrow(h)(e,l,o+1),--f);return 100==y&&(f=0),e.setOperator(e.getOperator(n-1)+f,n-1),e.normalize(),e}();return o<r.maxOps+10&&r.arrowFuncMap.set("".concat(t.toString()," ").concat(a.toString()," ").concat(i.toString()," ").concat(o),c.clone()),c}}},{key:"anyarrow_log",value:function(e){var t=this.clone(),a=new r(e),n=a.toNumber();if(a.gt(u))throw new Error("[PowiainaNum 0.2 error]Not implemented");return!a.isInt()||a.lt(0)?function(){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}:a.eq(0)?function(r){return t.div(r)}:a.eq(1)?function(r){return t.log(r)}:a.eq(2)?function(r){return t.slog(r)}:t.isInfiNaN()?function(){return t}:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=new r(e);if(o.isNaN())return o;if(o.isInfi())return r.ZERO.clone();if(t.isZero())return r.ONE.clone();if(t.eq(r.ONE))return r.ZERO.clone();if(t.eq(o))return r.ONE.clone();if(t.max(o).gt(r.arrowMSI(n+1)))return t.gt(o)?t:r.ZERO.clone();if(t.max(o).gt(r.arrowMSI(n))&&t.gt(o))return t.setOperator(t.getOperator(n)-1,n),t.normalize(),t.sub(t.getOperator(n-1));if(t.lt(r.ZERO.clone())){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}var i=0,u=t.getOperator(n)-o.getOperator(n);if(u>3){var l=u-3;i+=l,t.setOperator(t.getOperator(n)-l,n)}for(var s=0;s<100;++s)if(t.lt(r.ZERO))t=t.arrow(n-1)(e),--i;else{if(t.lte(1))return new r(i+t.toNumber()-1);++i,t=t.anyarrow_log(n-1)(e,a+1)}if(t.gt(10))return new r(i);if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}}},{key:"arrow_height_inverse",value:function(r){return this.anyarrow_log(r)}},{key:"chain",value:function(r,e){return this.arrow(e)(r)}},{key:"pentate",value:function(r,e){return this.arrow(3)(r,e)}},{key:"hexate",value:function(r,e){return this.arrow(4)(r,e)}},{key:"pent",value:function(r,e){return this.arrow(3)(r,e)}},{key:"penta_log",value:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return this.anyarrow_log(3)(r)}},{key:"expansion",value:function(e){var t,a=new r(e),n=this.clone();if(a.lt(r.ZERO)||!a.isInt())return r.NaN.clone();if(a.eq(r.ONE))return this.clone();if(this.eq(r.ONE))return r.ONE.clone();if(!this.isInt()){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(this.eq(2))return new r(4);if(a.eq(0))return r.ONE.clone();if(n.gt("10{1,2}".concat(u))||a.gt(u)){n.gt("10{1,2}".concat(u))?((t=n.clone()).setOperator(t.getOperator(1,2)-1,1,2),t.normalize()):t=n.gt("10{".concat(u,"}10"))?new r(n.getOperator(1/0)):r.ZERO;var o=t.add(a);return o.setOperator(o.getOperator(1,2)+1,1,2),o.normalize(),o}var i,l=a.toNumber()-1;for(t=n.clone(),i=0;0!==l&&t.lt(u)&&i<100;++i)l>0&&(t=n.arrow(t)(n),--l);return 100==i&&(l=0),t.setOperator(t.getOperator(1/0)+l,1/0),t.normalize(),t}},{key:"expansionArrow",value:function(e){var t=new r(e),a=this.clone();if(t.lt(0)||!t.isInt()||t.isNaN()||this.isNaN())return function(){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()};if(t.eq(0))return function(r){return a.arrow(r)(a)};if(t.eq(1))return function(r){return a.expansion(r)};var n=t;return function(e){var t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=new r(e);if(a.isNaN()||i.isNaN())return r.NaN.clone();if(i.lt(r.ZERO)){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(a.eq(r.ZERO)){if(i.eq(r.ONE))return r.ZERO.clone();if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(a.eq(r.ONE))return r.ONE.clone();if(i.eq(r.ZERO))return r.ONE.clone();if(i.eq(r.ONE))return a.clone();if(n.gt(r.MSI))return(t=n.clone()).setOperator(t.getOperator(1/0,2)+1,1/0,2),t;var l=n.toNumber();if(i.eq(2))return a.expansionArrow(l-1)(a,o+1);if(a.max(i).gt("10{".concat(l+1,",2}").concat(u)))return a.max(i);if(a.gt("10{".concat(l,",2}").concat(u))||i.gt(u)){a.gt("10{".concat(l,",2}").concat(u))?((t=a.clone()).setOperator(t.getOperator(l,2)-1,l,2),t.normalize()):t=a.gt("10{".concat(l-1,",2}").concat(u))?new r(a.getOperator(l-1,2)):r.ZERO;var s=t.add(i);return s.setOperator(s.getOperator(l,2)+1,l,2),s.normalize(),s}if(o>=r.maxOps+10)return new r({small:!1,sign:1,layer:0,array:[g(10,0),g(1,l,2)]});var c=i.toNumber(),f=Math.floor(c),h=n.sub(r.ONE);t=a.expansionArrow(h)(c-f,o+1);for(var y=0,N=new r("10{".concat(l-1,",2}").concat(u));0!==f&&t.lt(N)&&y<100;y++)f>0&&(t=a.expansionArrow(h)(t,o+1),--f);return 100==y&&(f=0),t.setOperator(t.getOperator(l-1,2)+f,l-1,2),t.normalize(),t}}},{key:"multiExpansion",value:function(r){return this.expansionArrow(2)(r)}},{key:"powerExpansion",value:function(r){return this.expansionArrow(3)(r)}},{key:"explosion",value:function(e){return r.BEAF(this,e,1,3)}},{key:"megotion",value:function(e){return r.BEAF(this,e,1,1,2)}},{key:"powiaination",value:function(e){return r.BEAF(this,e,1,1,1,2)}},{key:"abs",value:function(){var r=this.clone();return r.sign<0&&(r.sign*=-1),r}},{key:"clampMin",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.max.apply(r,[this].concat(t))}},{key:"clampMax",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.min.apply(r,[this].concat(t))}},{key:"clamp",value:function(r,e){return this.max(r).min(e)}},{key:"max",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.max.apply(r,[this].concat(t))}},{key:"min",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.min.apply(r,[this].concat(t))}},{key:"maxabs",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var o=t.map((function(e){return new r(e).abs()}));return r.max.apply(r,[this.abs()].concat(a(o)))}},{key:"minabs",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var o=t.map((function(e){return new r(e).abs()}));return r.min.apply(r,[this.abs()].concat(a(o)))}},{key:"cmpabs",value:function(e){var t=new r(e).abs();return this.abs().cmp(t)}},{key:"compare",value:function(e){var t=new r(e);if(this.isNaN()||t.isNaN())return 2;if(this.sign<t.sign)return-1;if(this.sign>t.sign)return 1;var a=-1==this.sign&&-1==t.sign;if(this.small&&!t.small)return-1*(a?-1:1);if(t.small&&!this.small)return 1*(a?-1:1);var n=1;this.small&&t.small&&(n*=-1),a&&(n*=-1);for(var o=0,i=0;this.array.length-1-i>=0&&t.array.length-1-i>=0;i++){var u=this.array[this.array.length-1-i],l=t.array[t.array.length-1-i];if(u.repeat===1/0&&l.repeat===1/0)return this.small===t.small?0:t.small?1:-1;if(u.repeat===1/0){o=1;break}if(l.repeat===1/0){o=-1;break}var s=y([u.megota,u.expans,u.arrow,u.repeat],[l.megota,l.expans,l.arrow,l.repeat]);if(1==s){o=1;break}if(-1==s){o=-1;break}}return o*n+1-1}},{key:"cmp",value:function(r){return this.compare(r)}},{key:"eq",value:function(r){return 0===this.cmp(r)}},{key:"neq",value:function(r){return 0!==this.cmp(r)}},{key:"lt",value:function(r){return-1===this.cmp(r)}},{key:"lte",value:function(r){return this.cmp(r)<=0}},{key:"gt",value:function(r){return 1==this.cmp(r)}},{key:"gte",value:function(r){var e=this.cmp(r);return 0==e||1==e}},{key:"equals",value:function(r){return this.eq(r)}},{key:"notEquals",value:function(r){return this.neq(r)}},{key:"eq_tolerance",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-7,a=new r(e);return this.sub(a).lte(this.max(a).mul(t))}},{key:"sin",value:function(){var e=this.clone();if(e.isneg())return e.neg().sin().neg();var t=e.mod(7074237752028440);return r.fromNumber(Math.sin(t.toNumber()))}},{key:"cos",value:function(){return this.sub(Math.PI/2).sin()}},{key:"tan",value:function(){return this.sin().div(this.cos())}},{key:"cot",value:function(){return this.cos().div(this.sin())}},{key:"sec",value:function(){return this.cos().rec()}},{key:"csc",value:function(){return this.sin().rec()}},{key:"neg",value:function(){var r=this.clone();return r.sign*=-1,r.normalize(),r}},{key:"rec",value:function(){var r=this.clone();return r.small=!r.small,r}},{key:"recip",value:function(){return this.rec()}},{key:"reciprocate",value:function(){return this.rec()}},{key:"floor",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?r.ZERO.clone():r.ONE.neg().clone();var e=this.abs();return e.array[0].repeat=Math[1==this.sign?"floor":"ceil"](e.getOperator(0)),e.sign=this.sign,e}},{key:"ceil",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?r.ONE.clone():r.ZERO.clone();var e=this.abs();return e.array[0].repeat=Math[1==this.sign?"ceil":"floor"](e.getOperator(0)),e.sign=this.sign,e}},{key:"round",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?this.rec().lte(2)?r.ONE.clone():r.ZERO.clone():this.abs().rec().lte(2)?r.ZERO.clone():r.ONE.neg().clone();var e=this.abs();return e.array[0].repeat=Math.round(e.array[0].repeat),e.sign=this.sign,e}},{key:"trunc",value:function(){var r=this.clone();return r.gte(0)?r.floor():r.ceil()}},{key:"isNaN",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return isNaN(this.getOperator(0))}))},{key:"isZero",value:function(){return Boolean(this.small&&!isFinite(this.getOperator(0)))}},{key:"isFinite",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return Boolean(this.small||isFinite(this.getOperator(0)))&&!this.isNaN()}))},{key:"isInfi",value:function(){return this.rec().isZero()}},{key:"isInfiNaN",value:function(){return this.isInfi()||this.isNaN()}},{key:"isInt",value:function(){return!!this.isZero()||(!(this.small||!Number.isInteger(this.getOperator(0)))||!!this.abs().gte(u/2))}},{key:"ispos",value:function(){return this.sign>0}},{key:"isneg",value:function(){return this.sign<0}},{key:"getOperatorIndex",value:function(r){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=0;a<this.array.length;a++){var n=y([this.array[a].megota,this.array[a].expans,this.array[a].arrow],[t,e,r]);if(0==n)return a;if(1==n)return a-.5}return this.array.length-.5}},{key:"getOperator",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=this.getOperatorIndex(r,e,t);return this.array[a]?this.array[a].repeat:0}},{key:"setOperator",value:function(r,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=this.getOperatorIndex(e,t,a);return this.array[n]?(this.array[n].repeat=r,!1):(this.array.splice(Math.ceil(n),0,{arrow:e,expans:t,megota:a,valuereplaced:t===1/0?1:e==1/0?0:-1,repeat:r}),!0)}},{key:"toNumber",value:function(){return-1==this.sign?-this.neg().toNumber():this.small?1/this.rec().toNumber():this.array.length>2?1/0:1==this.array.length?this.array[0].repeat:2==this.array.length&&1==this.array[1].arrow&&1==this.array[1].expans&&1==this.array[1].megota&&1==this.array[1].repeat?Math.pow(10,this.getOperator(0)):NaN}},{key:"toString_core",value:function(){if(this.isNaN())return"NaN";if(-1==this.sign)return"-".concat(this.neg().toString());if(this.small)return this.isZero()?"0":"/".concat(this.rec().toString());if(this.isInfi())return"Infinity";var r="";this.layer?this.layer<3?r+="P".repeat(this.layer):r+="P^"+this.layer+" ":r+="";for(var e=this.array.length-1;e>=0;e--){var t=this.array[e],a="10{".concat(t.arrow===1/0?"!":t.arrow).concat(t.expans>1||t.megota>1?",".concat(t.expans===1/0?"!":t.expans):"").concat(t.megota>1?",".concat(t.megota):"","}");a=1==t.arrow&&1==t.expans&&1==t.megota&&t.repeat<5?"e".repeat(t.repeat):0==t.arrow&&1==t.expans&&1==t.megota?t.repeat.toString():t.repeat>1?"(".concat(a,")^").concat(t.repeat," "):"".concat(a),r+="".concat(a)}return r}},{key:"toString",value:function(){try{return this.toString_core()}catch(r){return console.error("Checked error when converting to string"),"NaN"}}},{key:"toJSON",value:function(){return"PN"+this.toString()}},{key:"arr01",get:function(){for(var r=[0],e=0;e<this.array.length;e++)0==e?r[0]=this.array[e].repeat:(r[e]=[0,0,0,0],r[e][0]=this.array[e].arrow==1/0?"x":this.array[e].arrow,r[e][1]=this.array[e].repeat,r[e][2]=this.array[e].expans==1/0?"x":this.array[e].expans,r[e][3]=this.array[e].megota);return r}},{key:"normalize",value:function(){var e=!0,t=this;void 0===this.array&&(t.array=[g(NaN,0,1,1)]),void 0===this.sign&&(this.sign=0),void 0===this.layer&&(this.layer=0);for(var a=0;a<this.array.length;a++)if(this.array[a].repeat==1/0)return this.array=[{arrow:0,expans:1,megota:1,repeat:1/0}],this.layer=0,this;for(var n=1;n<t.array.length;++n){var o=t.array[n];if(null!==o.arrow&&void 0!==o.arrow||(o.arrow=0),null!==o.expans&&void 0!==o.expans||(o.expans=1),null!==o.megota&&void 0!==o.megota||(o.megota=1),isNaN(o.arrow)||isNaN(o.repeat)||isNaN(o.expans)||isNaN(o.megota))return t.array=[g(NaN,0,1,1)],t;if(!isFinite(o.repeat)||!isFinite(o.megota))return t.array=[g(1/0,0,1,1)],t;Number.isInteger(o.arrow)||(o.arrow=Math.floor(o.arrow)),Number.isInteger(o.repeat)||(o.repeat=Math.floor(o.repeat)),Number.isInteger(o.expans)||(o.expans=Math.floor(o.expans)),Number.isInteger(o.megota)||(o.megota=Math.floor(o.megota))}t.array.length||(t.small=!t.small,t.array=[g(1/0)]);do{e=!1,this.array.sort(x);for(var i=1;i<t.array.length-1;++i)t.array[i].arrow==t.array[i+1].arrow&&t.array[i].expans==t.array[i+1].expans&&t.array[i].megota==t.array[i+1].megota&&(t.array[i].repeat+=t.array[i+1].repeat,t.array.splice(i+1,1),--i,e=!0);for(var s=1;s<t.array.length;++s)0===t.array[s].arrow||0!==t.array[s].repeat&&null!==t.array[s].repeat&&void 0!==t.array[s].repeat?0==t.array[s].arrow&&t.array[s].expans>=2&&(t.array[s].arrow=1/0,t.array[s].valuereplaced=0,t.array[s].expans=t.array[s].expans-1):(t.array.splice(s,1),--s);for(t.array.length>r.maxOps&&t.array.splice(1,t.array.length-r.maxOps),this.array.length>=2&&1==this.array[1].arrow&&this.array[1].repeat>=1&&this.array[0].repeat<l&&(this.setOperator(this.array[1].repeat-1,1),this.setOperator(Math.pow(10,this.array[0].repeat),0),e=!0),this.getOperator(0)>u&&isFinite(this.getOperator(0))&&(this.setOperator(this.getOperator(1)+1,1),this.setOperator(Math.log10(this.getOperator(0)),0),e=!0),this.array[this.array.length-1].megota>u?(this.layer++,this.array=[g(this.array[this.array.length-1].megota)],e=!0):this.layer&&1==this.array.length&&0===this.array[0].arrow&&(this.layer--,this.array=[g(10),g(1,10,10,this.array[0].repeat)],e=!0),1==this.array.length&&this.array[0].repeat<1&&(this.array[0].repeat=1/this.array[0].repeat,this.small=!this.small,e=!0),1==this.array.length&&1==this.array[0].repeat&&this.small&&(this.small=!1,e=!0),this.array.length>=2&&this.array[1].arrow>=u&&(this.array[0].repeat=this.array[1].arrow,this.array[1]=g(1,1/0,this.array[1].expans,this.array[1].megota));t.array.length>=2&&1==t.array[0].repeat&&t.array[1].repeat;)t.array[1].repeat>1?t.array[1].repeat--:t.array.splice(1,1),t.array[0].repeat=10,e=!0;t.array.length>=2&&t.array.length<r.maxOps&&t.array[0].repeat<u&&t.array[1].arrow>=2&&t.array[1].repeat>1&&isFinite(t.array[1].arrow)&&(t.array[1].repeat--,t.array.splice(1,0,g(t.array[0].repeat-1,t.array[1].arrow-1,t.array[1].expans,t.array[1].megota)),t.array[0].repeat=10,e=!0),t.array.length>=2&&t.array[0].repeat<u&&t.array[1].arrow>=2&&1==t.array[1].repeat&&isFinite(t.array[1].arrow)&&(t.array.splice(1,1,g(t.array[0].repeat-1,t.array[1].arrow-1,t.array[1].expans,t.array[1].megota)),t.array[0].repeat=10,e=!0),t.array.length>=2&&t.array[1].repeat>u&&t.array[1].arrow!==1/0&&(t.array[1].arrow++,t.array[0].repeat=t.array[1].repeat,t.array[1].repeat=1,e=!0),t.array.length>=2&&t.array[1].repeat>u&&t.array[1].arrow===1/0&&(t.array[1].arrow=1,t.array[1].expans++,t.array[0].repeat=t.array[1].repeat,t.array[1].repeat=1,e=!0)}while(e);return this}},{key:"clone",value:function(){var e=new r;return e.resetFromObject(this),e}},{key:"resetFromObject",value:function(r){if(r.array){this.array=[];for(var e=0;e<r.array.length;e++)this.array[e]={arrow:r.array[e].arrow,expans:r.array[e].expans,megota:r.array[e].megota,repeat:r.array[e].repeat,valuereplaced:r.array[e].valuereplaced};return this.small=r.small,this.sign=r.sign,this.layer=r.layer,this}}}],[{key:"add",value:function(e,t){return new r(e).add(t)}},{key:"plus",value:function(e,t){return new r(e).add(t)}},{key:"sub",value:function(e,t){return new r(e).sub(t)}},{key:"minus",value:function(e,t){return new r(e).sub(t)}},{key:"mul",value:function(e,t){return new r(e).mul(t)}},{key:"times",value:function(e,t){return new r(e).mul(t)}},{key:"div",value:function(e,t){return new r(e).div(t)}},{key:"divide",value:function(e,t){return new r(e).div(t)}},{key:"mod",value:function(e,t){return new r(e).mod(t)}},{key:"modulus",value:function(e,t){return new r(e).mod(t)}},{key:"pow",value:function(e,t){return new r(e).pow(t)}},{key:"root",value:function(e,t){return new r(e).root(t)}},{key:"sqrt",value:function(e){return new r(e).sqrt()}},{key:"cbrt",value:function(e){return new r(e).cbrt()}},{key:"log10",value:function(e){return new r(e).log10()}},{key:"log",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new r(e).log(t)}},{key:"log2",value:function(e){return new r(e).log2()}},{key:"logBase",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new r(e).log(t)}},{key:"pLog10",value:function(e){return new r(e).pLog10()}},{key:"exp",value:function(e){return new r(e).pow_base(Math.E)}},{key:"factorial",value:function(e){return new r(e).factorial()}},{key:"gamma",value:function(e){return new r(e).gamma()}},{key:"lambertw",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new r(e).lambertw(t)}},{key:"affordGeometricSeries",value:function(e,t,a,n){return this.affordGeometricSeries_core(new r(e),new r(t),new r(a),n)}},{key:"affordGeometricSeries_core",value:function(r,e,t,a){var n=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],o=e.mul(t.pow(a));return r.div(o).mul(t.sub(1)).add(1).clampMin(n?1:-1/0).log10().div(t.log10()).floor()}},{key:"sumGeometricSeries",value:function(e,t,a,n){return this.sumGeometricSeries_core(e,new r(t),new r(a),n)}},{key:"sumGeometricSeries_core",value:function(e,t,a,n){return t.mul(a.pow(n)).mul(r.sub(1,a.pow(e))).div(r.sub(1,a))}},{key:"affordArithmeticSeries",value:function(e,t,a,n){return this.affordArithmeticSeries_core(new r(e),new r(t),new r(a),new r(n))}},{key:"affordArithmeticSeries_core",value:function(r,e,t,a){var n=e.add(a.mul(t)).sub(t.div(2)),o=n.pow(2);return n.neg().add(o.add(t.mul(r).mul(2)).sqrt()).div(t).floor()}},{key:"sumArithmeticSeries",value:function(e,t,a,n){return this.sumArithmeticSeries_core(new r(e),new r(t),new r(a),new r(n))}},{key:"sumArithmeticSeries_core",value:function(r,e,t,a){var n=e.add(a.mul(t));return r.div(2).mul(n.mul(2).add(r.sub(1).mul(t)))}},{key:"tetrate",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return new r(e).tetrate(t,a)}},{key:"tetrate_10",value:function(e){return r.fromNumber(10).tetrate(e)}},{key:"iteratedlog",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;return new r(e).iteratedlog(t,a)}},{key:"arrow",value:function(e,t,a){return new r(e).arrow(t)(a)}},{key:"arrFrac",value:function(e,t){var a=new r(e).clone(),n=new r(t).clone();return new r(a).arrow(n.floor().add(1))(a.div(2).pow(n.sub(n.floor())).mul(2))}},{key:"arrowMSI",value:function(e){return new r("10{".concat(e,"}").concat(u))}},{key:"hyper",value:function(e){var t=new r(e);return t.eq(0)?function(e,t){return new r(t).eq(0)?new r(e):new r(e).add(1)}:t.eq(1)?r.add:t.eq(2)?r.mul:t.eq(3)?r.pow:function(e,a){return new r(e).arrow(t.sub(2))(a)}}},{key:"pentate",value:function(e,t,a){return new r(e).arrow(3)(t,a)}},{key:"hexate",value:function(e,t,a){return new r(e).arrow(4)(t,a)}},{key:"pent",value:function(e,t,a){return new r(e).arrow(3)(t,a)}},{key:"penta_log",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;return new r(e).anyarrow_log(3)(t)}},{key:"expansion",value:function(e,t){return new r(e).expansion(t)}},{key:"multiExpansion",value:function(e,t){return new r(e).multiExpansion(t)}},{key:"powerExpansion",value:function(e,t){return new r(e).powerExpansion(t)}},{key:"BEAF",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];function n(e){return void 0!==t[e]&&null!==t[e]?new r(t[e]):new r(1)}return n(0).eq(1)?new r(1):n(1).eq(1)?new r(n(0)):n(5).eq(2)&&(n(4).gte(2)||n(3).gte(2)||n(2).gte(2))||0!==t.slice(6).map((function(e){return new r(e)})).filter((function(r){return r.gt(1)})).length?r.POSITIVE_INFINITY.clone():r.BEAF_core(n(0),n(1),n(2),n(3),n(4),n(5))}},{key:"BEAF_core",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,l=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,c=new r(e),f=new r(t);function h(e){var t;return new r(null!==(t=[n,o,i,l][e])&&void 0!==t?t:1)}if(c.eq(1))return new r(1);if(f.eq(1))return new r(c);if(f.isZero())return new r(1);if(c.lt(0)){if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(new r(l).gte(3))return r.POSITIVE_INFINITY.clone();if(h(0).eq(1)&&h(1).eq(1)&&h(2).eq(1))return c.pow(f);if(h(0).eq(2)&&h(1).eq(1)&&h(2).eq(1)&&h(3).eq(1))return c.tetrate(f);if(h(1).eq(1)&&h(2).eq(1)&&h(3).eq(1))return c.arrow(h(0))(f);if(h(1).eq(2)&&h(2).eq(1)&&h(3).eq(1))return c.expansionArrow(h(0))(f);var y=h(0).toNumber(),N=h(1),p=h(2),m=h(3);if(m.eq(2)){if(1!=y)return r.POSITIVE_INFINITY.clone();if(N.neq(1))return r.POSITIVE_INFINITY.clone();if(p.neq(1))return r.POSITIVE_INFINITY.clone();if(f.gte(u))return r.POSITIVE_INFINITY.clone();var v=new r(10);return v.layer=f.toNumber(),v.normalize(),v}function w(r,e,t){return 0==r&&e>1?[1/0,e-1,t]:0==r&&1==e&&t>1?[1,1/0,t-1]:[r,e,t]}if(p.gt(u)){var b=new r(p);return b.layer++,b.normalize(),b}function E(r){return isFinite(r)?r.toString():"!"}function d(r,e,t){return"10{".concat(E(r),",").concat(E(e),",").concat(t,"}").concat(u)}var O=c.clone(),I=new r(h(0)),k=function(s){var h,y,m=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;console.log("".concat("-".repeat(m)," {").concat(e,",").concat(t,",").concat(n,",").concat(o,",").concat(i,"}"));var v,b=new r(s);if(O.isNaN()||b.isNaN())return r.NaN.clone();if(b.lt(r.ZERO))return r.NaN.clone();if(O.eq(r.ZERO)){if(b.eq(r.ONE))return r.ZERO.clone();if(r.throwErrorOnResultNaN)throw new Error("NaN");return r.NaN.clone()}if(O.eq(r.ONE))return r.ONE.clone();if(b.eq(r.ZERO))return r.ONE.clone();if(b.eq(r.ONE))return O.clone();if(I.eq(0))return r.BEAF(O,O,f,N.sub(1),p,l,m+1);if(N.eq(0))return r.BEAF(O,O,O,f,p.sub(1),l,m+1);if(p.eq(0))return r.BEAF(O,O,O,O,N,new r(l).sub(1),m+1);if(N.gt(u))return(v=new r(N)).setOperator(v.getOperator(1,1/0,p.toNumber())+1,1,1/0,p.toNumber()),v;if(I.gt(r.MSI))return(v=I.clone()).setOperator(v.getOperator(1/0,N.toNumber(),p.toNumber())+1,1/0,N.toNumber(),p.toNumber()),v;var E=I.toNumber();if(b.eq(2))return r.BEAF(O,O,E-1,N,p,l,m+1);if(O.max(b).gt(d(E+1,N.toNumber(),p.toNumber())))return O.max(b);if(O.gt(d(E,N.toNumber(),p.toNumber()))||b.gt(u)){O.gt(d(E,N.toNumber(),p.toNumber()))?((v=O.clone()).setOperator(v.getOperator(E,N.toNumber(),p.toNumber())-1,E,N.toNumber(),p.toNumber()),v.normalize()):v=O.gt(d.apply(void 0,a(w(E-1,N.toNumber(),p.toNumber()))))?new r(O.getOperator.apply(O,a(w(E-1,N.toNumber(),p.toNumber())))):r.ZERO;var k=v.add(b);return k.setOperator(k.getOperator(E,N.toNumber(),p.toNumber())+1,E,N.toNumber(),p.toNumber()),k.normalize(),k}if(m>=r.maxOps+10)return new r({small:!1,sign:1,layer:0,array:[g(10,0),g(1,E,N.toNumber(),p.toNumber())]});var x=b.toNumber(),M=Math.floor(x),q=I.sub(r.ONE);v=r.BEAF(O,x-M,q.toNumber(),N,p,l,m+1);for(var S=0,R=new r(d.apply(void 0,a(w(E-1,N.toNumber(),p.toNumber()))));0!==M&&v.lt(R)&&S<100;S++)M>0&&(v=r.BEAF(c,v,q.toNumber(),N,p,l,m+1),--M);return 100==S&&(M=0),(h=v).setOperator.apply(h,[(y=v).getOperator.apply(y,a(w(E-1,N.toNumber(),p.toNumber())))+M].concat(a(w(E-1,N.toNumber(),p.toNumber())))),v.normalize(),v}(f,s);return console.log("".concat("-".repeat(s)," = ").concat(k)),k}},{key:"abs",value:function(e){return new r(e).abs()}},{key:"max",value:function(){for(var e=r.NEGATIVE_INFINITY,t=arguments.length,a=new Array(t),n=0;n<t;n++)a[n]=arguments[n];for(var o=0;o<a.length;o++)e.lt(a[o])&&(e=new r(a[o]).clone());return e}},{key:"min",value:function(){for(var e=r.POSITIVE_INFINITY,t=arguments.length,a=new Array(t),n=0;n<t;n++)a[n]=arguments[n];for(var o=0;o<a.length;o++)e.gt(a[o])&&(e=new r(a[o]).clone());return e}},{key:"clampMin",value:function(){return r.max.apply(r,arguments)}},{key:"clampMax",value:function(){return r.min.apply(r,arguments)}},{key:"eq",value:function(e,t){return new r(e).eq(t)}},{key:"equals",value:function(e,t){return new r(e).eq(t)}},{key:"neq",value:function(e,t){return new r(e).neq(t)}},{key:"notEquals",value:function(e,t){return new r(e).notEquals(t)}},{key:"lt",value:function(e,t){return new r(e).lt(t)}},{key:"gt",value:function(e,t){return new r(e).gt(t)}},{key:"lte",value:function(e,t){return new r(e).lte(t)}},{key:"gte",value:function(e,t){return new r(e).gte(t)}},{key:"rec",value:function(e){return new r(e).rec()}},{key:"recip",value:function(e){return new r(e).rec()}},{key:"reciprocate",value:function(e){return new r(e).rec()}},{key:"floor",value:function(e){return new r(e).floor()}},{key:"ceil",value:function(e){return new r(e).ceil()}},{key:"round",value:function(e){return new r(e).round()}},{key:"trunc",value:function(e){return new r(e).trunc()}},{key:"sign",value:function(e){return new r(e).sign}},{key:"isNaN",value:function(e){return new r(e).isNaN()}},{key:"fromNumber",value:function(e){var t=new r;if(t.resetFromObject({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),Number.isNaN(e))return t;if(e<0)t.sign=-1;else{if(0==e)return t.sign=0,t.small=!0,t.array=[g(1/0,0)],t;e>0&&(t.sign=1)}var a=Math.abs(e);return a==1/0?t.array=[g(1/0,0)]:a>=s&&a<1?(t.small=!0,t.array=[g(1/a,0)]):a<s?(t.small=!0,t.array=[g(-Math.log10(a),0),g(1,1)]):a<=u?t.array=[g(a,0)]:(t.setOperator(Math.log10(a),0),t.array=[g(Math.log10(a),0),g(1,1)]),t}},{key:"fromString",value:function(e){if(r.usingBreakEternityLikeFromString&&h.test(e)){var t=e.match(/(e+-)(\d+(.\d+)?)/);if(t){var a=t[1].length;e="e-"+"e".repeat(a-1)+t[2]}}return this.fromString_core(e)}},{key:"fromString_core",value:function(e){var t,a,n,o,i,s,c,h=new r(NaN);if(e.startsWith("PN")&&(e=e.substring(2)),"NaN"==e)return r.NaN.clone();if(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/J\^(\d+)/g,"(10{!})^$1")).replace(/J/g,"10{!}")).replace(/K\^(\d+)/g,"(10{1,2})^$1")).replace(/K/g,"10{1,2}")).replace(/L\^(\d+)/g,"(10{2,2})^$1")).replace(/L/g,"10{2,2}")).replace(/M\^(\d+)/g,"(10{!,2})^$1")).replace(/M/g,"10{!,2}")).replace(/N\^(\d+)/g,"(10{1,!})^$1")).replace(/N/g,"10{1,!}"),/^.*e-.*(e|\^).*/.test(e)&&(e="/10^"+e.substring(e.indexOf("e-"))),!isNaN(Number(e))){var y=Number(e),p=!1;if(0==y?/^((0)|(0*\.0+e\d+)|(0*\.0*))$/.test(e)&&(p=!0):p=!0,!p){var m=e.search(/e/),v=e.substring((-1==m?e.length:m)+1),w=e.substring(0,-1==m?void 0:m),b=[0,0];if(b[1]=Number(v||"0"),Number(w)>=1){var E=w.length>=17?N(w):Math.log10(Number(w)),d=Math.floor(E),O=E-d;b[0]=Math.pow(10,O),b[1]+=d}else{var I=(c=w.match(/^0\.(0*)[1-9]/))?c[1].length:0;w=(w=w.substring(w.search(/[1-9]/))).charAt(0)+"."+w.substring(1),I+=1,b[0]=Number(w),b[1]+=-I}return r.pow(10,-b[1]-1).mul(10*Math.pow(b[0],-1)).rec()}if(isFinite(y)&&p)return h=r.fromNumber(Number(e))}if(-1!==e.indexOf("l")&&-1!==e.indexOf("s")&&-1!==e.indexOf("a")){var k=function(r){var e=r.match(/l(\d+)\s+s(\d+)\s+a(\[.*\])/);try{if(e)return{lValue:parseInt(e[1]),sValue:parseInt(e[2]),array:JSON.parse(e[3])}}catch(r){return null}return null}(e);if(!k||0!==k.sValue&&1!==k.sValue&&-1!==k.sValue)throw"[PowiainaNum 0.2 error]malformed input: "+e;return(h=r.fromObject(k.array)).layer=k.lValue,h.sign=k.sValue,h.small=!1,h.normalize(),h}if(e=function(r){for(var e="",t=!1,a=0;a<r.length;a++){var n=r[a];"{"===n?(t=!0,e+=n):"}"===n?(t=!1,e+=n):","===n?t&&(e+=n):e+=n}return e}(e=e.replace(/\(e\^(\d+)\)/g,"(10^)^$1 ").replace(/(\d+)[Pp][Tt]/g,"(10^)^$1 ")),!f.test(e))throw"[PowiainaNum 0.2 error]malformed input: "+e;var x=!1,M=!1;if("-"==e[0]||"+"==e[0]){var q=e.search(/[^-\+]/);x=(null!==(a=null===(t=e.substring(0,q).match(/-/g))||void 0===t?void 0:t.length)&&void 0!==a?a:0)%2==1,e=e.substring(q)}if("/"==e[0]){var S=e.search(/[^\/]/);M=(null!==(o=null===(n=e.substring(0,S).match(/\//g))||void 0===n?void 0:n.length)&&void 0!==o?o:0)%2==1,e=e.substring(S)}if("NaN"==e)h.array=[g(NaN)];else if("Infinity"==e)h.array=[g(1/0)];else{var R,T,_,F;for(h.sign=1,h.array=[g(0)],"P"==e[0]&&("^"==e[1]?(R=e.substring(2).search(/[^0-9]/)+2,h.layer=Number(e.substring(2,R)),e=e.substring(R+1)):(R=e.search(/[^P]/),h.layer=R,e=e.substring(R)));e&&/^(\(?10[\^\{])/.test(e);){var A=void 0,Z=void 0,P=void 0;if("("==e[0]&&(e=e.substring(1)),"^"==e[2])A=R=e.substring(2).search(/[^\^]/),T=R+2;else{R=e.indexOf("}");var V=e.substring(3,R).split(",");A=Number("!"==V[0]?1/0:V[0]),Z=Number(null!==(i="!"==V[1]?1/0:V[1])&&void 0!==i?i:1),P=Number(null!==(s=V[2])&&void 0!==s?s:1),T=R+1}")"==(e=e.substring(T))[0]?(R=e.indexOf(" "),_=Number(e.substring(2,R)),e=e.substring(R+1)):_=1,1==A&&1==Z&&1==P?h.array.length>=2&&1==h.array[1].arrow?h.array[1].repeat+=_:h.array.splice(1,0,g(_,1,Z,P)):2==A&&1==Z&&1==P?(R=h.array.length>=2&&1==h.array[1].arrow?h.array[1].repeat:0,(T=h.array[0].repeat)>=1e10&&++R,T>=10&&++R,h.array[0].repeat=R,h.array.length>=2&&1==h.array[1].arrow&&h.array.splice(1,1),F=h.getOperatorIndex(2),Number.isInteger(F)?h.array[F].repeat+=_:h.array.splice(Math.ceil(F),0,g(_,2,Z,P))):isFinite(A)?(R=h.getOperator(A-1),(T=h.getOperator(A-2))>=10&&++R,F=h.getOperatorIndex(A),h.array.splice(1,Math.ceil(F)-1),h.array[0].repeat=R,Number.isInteger(F)?h.array[1].repeat+=_:h.array.splice(1,0,g(_,A,Z,P))):h.array.splice(1,0,g(_,A,Z,P))}R=e.split(/[Ee]/),T=[h.array[0].repeat,0],_=1;for(var Y=R.length-1;Y>=0;--Y){T[0]<l&&0===T[1]?T[0]=Math.pow(10,_*T[0]):-1==_?(0===T[1]?T[0]=Math.pow(10,_*T[0]):1==T[1]&&T[0]<=Math.log10(Number.MAX_VALUE)?T[0]=Math.pow(10,_*Math.pow(10,T[0])):T[0]=0,T[1]=0):T[1]++;var z=R[Y].indexOf("."),G=-1==z?R[Y].length:z;0===T[1]?G>=17?(T[0]=Math.log10(T[0])+N(R[Y].substring(0,G)),T[1]=1):R[Y]&&(T[0]*=Number(R[Y])):(F=G>=17?N(R[Y].substring(0,G)):R[Y]?Math.log10(Number(R[Y])):0,1==T[1]?T[0]+=F:2==T[1]&&T[0]<l+Math.log10(F)&&(T[0]+=Math.log10(1+Math.pow(10,Math.log10(F)-T[0])))),T[0]<l&&T[1]?(T[0]=Math.pow(10,T[0]),T[1]--):T[0]>u&&(T[0]=Math.log10(T[0]),T[1]++)}h.array[0].repeat=T[0],T[1]&&(h.array.length>=2&&1==h.array[1].arrow&&1==h.array[1].expans&&1==h.array[1].megota?h.array[1].repeat+=T[1]:h.array.splice(1,0,g(T[1],1,1,1)))}return x&&(h.sign*=-1),M&&(h.small=!h.small),h.normalize(),h.normalize(),h}},{key:"fromObject",value:function(e){var t=new r;if(t.resetFromObject({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),t.array=[],function(r){if(!Array.isArray(r))return!1;for(var e=0;e<r.length;e++){var t=r[e];if(!Array.isArray(t))return!1;if(!v(t))return!1;if(!w(t))return!1}return!0}(e)){for(var a=0;a<e.length;a++)t.array[a]={arrow:e[a][0],expans:1,megota:1,repeat:e[a][1]};return t.small=!1,t.sign=1,t.layer=0,t}if(function(r){if(!Array.isArray(r))return!1;if("number"!=typeof r[0])return!1;for(var e=1;e<r.length;e++){var t=r[e];if(!Array.isArray(t))return!1;if(!E(t))return!1;if(!d(t)&&!O(t)&&!I(t))return!1}return!0}(e)){var n=e;t.array[0]=g(n[0]);for(var o=1;o<n.length;o++){var i=n[o];t.array[1]=g(i[1],b(i[0]),b(i[2]),i[3])}return t.small=!1,t.sign=1,t.layer=0,t}return t.resetFromObject(e),t}},{key:"grahalFunction",value:function(e){var t=new r(e);return!t.isInt()||t.lt(0)||t.isNaN()?r.NaN.clone():t.eq(1)?new r("10^^^(10^)^7625597484984 3638334640023.7783"):t.lte(u)?new r("(10{!})^".concat(t.toNumber()," 10^^^(10^)^7625597484984 3638334640023.7783")):r.BEAF(3,t,1,2)}}])}();i=Symbol.toStringTag,q.ZERO=new q({array:[{arrow:0,expans:1,megota:1,repeat:1/0}],small:!0,layer:0,sign:0}),q.ONE=new q({array:[{arrow:0,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),q.MSI=new q(u),q.MSI_REC=((M=new q(u)).small=!0,M),q.E_MSI=new q({array:[{arrow:0,expans:1,megota:1,repeat:u},{arrow:1,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),q.EE_MSI=new q({array:[{arrow:0,expans:1,megota:1,repeat:u},{arrow:1,expans:1,megota:1,repeat:2}],small:!1,layer:0,sign:1}),q.E_MSI_REC=new q({array:[{arrow:0,expans:1,megota:1,repeat:u},{arrow:1,expans:1,megota:1,repeat:1}],small:!0,layer:0,sign:1}),q.TETRATED_MSI=new q({array:[{arrow:0,expans:1,megota:1,repeat:1e10},{arrow:1,expans:1,megota:1,repeat:u-2}],small:!1,layer:0,sign:1}),q.PENTATED_MSI=new q({array:[{arrow:0,expans:1,megota:1,repeat:10},{arrow:2,expans:1,megota:1,repeat:u-1}],small:!1,layer:0,sign:1}),q.TRITRI=new q({small:!1,layer:0,sign:1,array:[g(3638334640023.7783,0,1,1),g(7625587484984,1,1,1)]}),q.GRAHAMS_NUMBER=new q("(10{!})^63 10^^^(10^)^7625597484984 3638334640023.7783"),q.POSITIVE_INFINITY=new q(1/0),q.NEGATIVE_INFINITY=new q(-1/0),q.NaN=new q({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),q.E=new q(Math.E),q.LN2=new q(Math.LN2),q.LN10=new q(Math.LN10),q.LOG2E=new q(Math.LOG2E),q.LOG10E=new q(Math.LOG10E),q.PI=new q(Math.PI),q.SQRT1_2=new q(Math.SQRT1_2),q.SQRT2=new q(Math.SQRT2),q.maxOps=100,q.POW_2_44_MOD_PI=1.701173079953,q.arrowFuncMap=new Map,q.usingBreakEternityLikeFromString=!0,q.blankArgumentConstructorReturnZero=!1,q.throwErrorOnResultNaN=!1,r.arraySortFunction=x,r.default=q,r.mergeSameArrays=function(r){for(var e=1;e<r.array.length-1;++e)r.array[e].arrow==r.array[e+1].arrow&&r.array[e].expans==r.array[e+1].expans&&r.array[e].megota==r.array[e+1].megota&&(r.array[e].repeat+=r.array[e+1].repeat,r.array.splice(e+1,1),--e)},Object.defineProperty(r,"__esModule",{value:!0})}));
package/dist/index.d.ts CHANGED
@@ -272,7 +272,8 @@ export default class PowiainaNum implements IPowiainaNum {
272
272
  /**
273
273
  * -1: `this` is smaller
274
274
  * 0: equals
275
- * 1: `x` is bigger
275
+ * 1: `x` is smaller
276
+ * 2: NaN
276
277
  */
277
278
  compare(x: PowiainaNumSource): -1 | 0 | 1 | 2;
278
279
  cmp(other: PowiainaNumSource): -1 | 0 | 1 | 2;
@@ -495,12 +496,17 @@ export default class PowiainaNum implements IPowiainaNum {
495
496
  static readonly POW_2_44_MOD_PI = 1.701173079953;
496
497
  static arrowFuncMap: Map<string, PowiainaNum>;
497
498
  /**
498
- * If you set this config to true, the `fromString` method will try to parse the string to `PowiainaNum` class with `break_eternity.js` similar `fromString` method, if cannot parse correctly, the program will use `PowiainaNum.js` `fromString` method.
499
+ * If you set this config to true,
500
+ * the `fromString` method will try to parse the string to `PowiainaNum` class with `break_eternity.js` similar `fromString` method, if cannot parse correctly, the program will use `PowiainaNum.js` `fromString` method.
499
501
  */
500
502
  static usingBreakEternityLikeFromString: boolean;
501
503
  /**
502
504
  * If you set this config to true, the `constructor` method will return Zero instead of NaN when call new PowiainaNum() with no arguments.
503
505
  */
504
506
  static blankArgumentConstructorReturnZero: boolean;
507
+ /**
508
+ * If you set this config to true, when calucation returns NaN, the program will throw error.
509
+ */
510
+ static throwErrorOnResultNaN: boolean;
505
511
  }
506
512
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powiaina_num.js",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "A JavaScript library that handles arithmetic for numbers as large as {10,9e15,1,1,1,2}.",
5
5
  "type": "module",
6
6
  "main": "dist/PowiainaNum.cjs.js",