powiaina_num.js 0.2.13 → 0.2.15

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.
@@ -9,6 +9,9 @@
9
9
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
10
10
  return n;
11
11
  }
12
+ function _arrayWithHoles(r) {
13
+ if (Array.isArray(r)) return r;
14
+ }
12
15
  function _arrayWithoutHoles(r) {
13
16
  if (Array.isArray(r)) return _arrayLikeToArray(r);
14
17
  }
@@ -29,9 +32,42 @@
29
32
  function _iterableToArray(r) {
30
33
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
31
34
  }
35
+ function _iterableToArrayLimit(r, l) {
36
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
37
+ if (null != t) {
38
+ var e,
39
+ n,
40
+ i,
41
+ u,
42
+ a = [],
43
+ f = !0,
44
+ o = !1;
45
+ try {
46
+ if (i = (t = t.call(r)).next, 0 === l) {
47
+ if (Object(t) !== t) return;
48
+ f = !1;
49
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
50
+ } catch (r) {
51
+ o = !0, n = r;
52
+ } finally {
53
+ try {
54
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
55
+ } finally {
56
+ if (o) throw n;
57
+ }
58
+ }
59
+ return a;
60
+ }
61
+ }
62
+ function _nonIterableRest() {
63
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
64
+ }
32
65
  function _nonIterableSpread() {
33
66
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
34
67
  }
68
+ function _slicedToArray(r, e) {
69
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
70
+ }
35
71
  function _toConsumableArray(r) {
36
72
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
37
73
  }
@@ -386,6 +422,7 @@
386
422
  } catch (e) {
387
423
  console.error("Malformed input");
388
424
  console.error(e);
425
+ if (PowiainaNum.throwErrorOnResultNaN && PowiainaNum.isNaN(this)) throw new Error("NaN");
389
426
  }
390
427
  }
391
428
  //#region 4 Basic calculates.
@@ -400,7 +437,10 @@
400
437
  var x = this.clone().normalize();
401
438
  var y = new PowiainaNum(other);
402
439
  // 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();
440
+ if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY)) {
441
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
442
+ return PowiainaNum.NaN.clone();
443
+ }
404
444
  // inf & nan check
405
445
  if (!x.isFinite()) return x.clone();
406
446
  if (!y.isFinite()) return y.clone();
@@ -497,7 +537,10 @@
497
537
  var y = new PowiainaNum(other);
498
538
  // inf * -inf = -inf
499
539
  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();
540
+ if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero()) {
541
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
542
+ return PowiainaNum.NaN.clone();
543
+ }
501
544
  if (x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.POSITIVE_INFINITY.clone();
502
545
  // inf & nan check
503
546
  if (!x.isFinite()) return x.clone();
@@ -602,6 +645,7 @@
602
645
  return this.neg().pow(other).neg();
603
646
  }
604
647
  }
648
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
605
649
  return PowiainaNum.NaN.clone();
606
650
  }
607
651
  var r = this.abs().pow(other);
@@ -631,6 +675,7 @@
631
675
  } else if (other.rec().mod(2).eq(1)) {
632
676
  return this.neg().log10().mul(other).pow10().neg();
633
677
  }
678
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
634
679
  return PowiainaNum.NaN.clone();
635
680
  }
636
681
  }, {
@@ -658,7 +703,10 @@
658
703
  }, {
659
704
  key: "log10",
660
705
  value: function log10() {
661
- if (this.isneg()) return PowiainaNum.NaN.clone();
706
+ if (this.isneg()) {
707
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
708
+ return PowiainaNum.NaN.clone();
709
+ }
662
710
  if (this.isZero()) return PowiainaNum.NEGATIVE_INFINITY.clone();
663
711
  if (this.small) {
664
712
  var _x = this.clone();
@@ -800,6 +848,7 @@
800
848
  var princ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
801
849
  var principal = princ;
802
850
  if (this.lt(-0.3678794411710499)) {
851
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
803
852
  return PowiainaNum.NaN.clone(); //complex
804
853
  } else if (principal) {
805
854
  if (this.abs().lt("1e-300")) return new PowiainaNum(this);else if (this.small) {
@@ -814,6 +863,7 @@
814
863
  }
815
864
  } else {
816
865
  if (this.sign === -1) {
866
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
817
867
  return PowiainaNum.NaN.clone(); //complex
818
868
  }
819
869
  if (this.lt(9e15)) {
@@ -837,7 +887,10 @@
837
887
  var t = this.clone();
838
888
  var other = new PowiainaNum(other2);
839
889
  var payl = new PowiainaNum(payload);
840
- if (t.isNaN() || other.isNaN() || payl.isNaN()) return PowiainaNum.NaN.clone();
890
+ if (t.isNaN() || other.isNaN() || payl.isNaN()) {
891
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
892
+ return PowiainaNum.NaN.clone();
893
+ }
841
894
  if (t.eq(1)) return PowiainaNum.ONE.clone();
842
895
  if (payl.neq(PowiainaNum.ONE) && t.gte(EXP_E_REC)) {
843
896
  other = other.add(payl.slog(t));
@@ -848,14 +901,23 @@
848
901
  negln = this.log().neg();
849
902
  return negln.lambertw().div(negln);
850
903
  }
851
- if (other.lte(-2)) return PowiainaNum.NaN.clone();
904
+ if (other.lte(-2)) {
905
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
906
+ return PowiainaNum.NaN.clone();
907
+ }
852
908
  if (t.isZero()) {
853
- if (other.isZero()) return PowiainaNum.NaN.clone();
909
+ if (other.isZero()) {
910
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
911
+ return PowiainaNum.NaN.clone();
912
+ }
854
913
  if (other.gte(MSI / 2) || other.toNumber() % 2 == 0) return PowiainaNum.ZERO.clone();
855
914
  return PowiainaNum.ONE.clone();
856
915
  }
857
916
  if (t.eq(PowiainaNum.ONE)) {
858
- if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.NaN.clone();
917
+ if (other.eq(PowiainaNum.ONE.neg())) {
918
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
919
+ return PowiainaNum.NaN.clone();
920
+ }
859
921
  return PowiainaNum.ONE.clone();
860
922
  }
861
923
  if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.ZERO.clone();
@@ -929,7 +991,10 @@
929
991
  if (b.lt(EXP_E_REC)) {
930
992
  var a = b.tetrate(Infinity);
931
993
  if (x.eq(a)) return PowiainaNum.POSITIVE_INFINITY.clone();
932
- if (x.gt(a)) return PowiainaNum.NaN.clone();
994
+ if (x.gt(a)) {
995
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
996
+ return PowiainaNum.NaN.clone();
997
+ }
933
998
  }
934
999
  if (x.max(b).gt(PowiainaNum.PENTATED_MSI)) {
935
1000
  if (x.gt(b)) return x;
@@ -973,13 +1038,17 @@
973
1038
  }
974
1039
  }
975
1040
  if (x.gt(10)) return new PowiainaNum(r);
1041
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
976
1042
  return PowiainaNum.NaN.clone();
977
1043
  }
978
1044
  }, {
979
1045
  key: "ssqrt",
980
1046
  value: function ssqrt() {
981
1047
  var x = this.clone();
982
- if (x.lt(1 / EXP_E_REC)) return PowiainaNum.NaN.clone();
1048
+ if (x.lt(1 / EXP_E_REC)) {
1049
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1050
+ return PowiainaNum.NaN.clone();
1051
+ }
983
1052
  if (!x.isFinite()) return x;
984
1053
  if (x.gt(PowiainaNum.TETRATED_MSI)) return x;
985
1054
  if (x.gt(PowiainaNum.EE_MSI)) {
@@ -1030,6 +1099,7 @@
1030
1099
  if (!arrows.isInt() || arrows.lt(PowiainaNum.ZERO)) {
1031
1100
  console.warn("The arrow is <0 or not a integer, the returned function will return NaN.");
1032
1101
  return function () {
1102
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1033
1103
  return PowiainaNum.NaN.clone();
1034
1104
  };
1035
1105
  }
@@ -1055,6 +1125,7 @@
1055
1125
  if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
1056
1126
  if (t.eq(PowiainaNum.ZERO)) {
1057
1127
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
1128
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1058
1129
  return PowiainaNum.NaN.clone();
1059
1130
  }
1060
1131
  if (payload.neq(PowiainaNum.ONE)) other = other.add(payload.anyarrow_log(arrows)(t));
@@ -1134,6 +1205,7 @@
1134
1205
  throw new Error(powiainaNumError + "Not implemented");
1135
1206
  }
1136
1207
  if (!arrow.isInt() || arrow.lt(0)) return function () {
1208
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1137
1209
  return PowiainaNum.NaN.clone();
1138
1210
  };
1139
1211
  if (arrow.eq(0)) return function (base) {
@@ -1167,7 +1239,10 @@
1167
1239
  return x.sub(x.getOperator(arrowsNum - 1));
1168
1240
  }
1169
1241
  }
1170
- if (x.lt(PowiainaNum.ZERO.clone())) return PowiainaNum.NaN.clone();
1242
+ if (x.lt(PowiainaNum.ZERO.clone())) {
1243
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1244
+ return PowiainaNum.NaN.clone();
1245
+ }
1171
1246
  // base^base^... = x? (? bases)
1172
1247
  var r = 0;
1173
1248
  // 计算x与base的差距
@@ -1191,6 +1266,7 @@
1191
1266
  }
1192
1267
  }
1193
1268
  if (x.gt(10)) return new PowiainaNum(r);
1269
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1194
1270
  return PowiainaNum.NaN.clone();
1195
1271
  };
1196
1272
  }
@@ -1250,7 +1326,10 @@
1250
1326
  if (other.lt(PowiainaNum.ZERO) || !other.isInt()) return PowiainaNum.NaN.clone();
1251
1327
  if (other.eq(PowiainaNum.ONE)) return this.clone();
1252
1328
  if (this.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
1253
- if (!this.isInt()) return PowiainaNum.NaN.clone();
1329
+ if (!this.isInt()) {
1330
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1331
+ return PowiainaNum.NaN.clone();
1332
+ }
1254
1333
  if (this.eq(2)) return new PowiainaNum(4);
1255
1334
  if (other.eq(0)) return PowiainaNum.ONE.clone();
1256
1335
  var r;
@@ -1290,6 +1369,7 @@
1290
1369
  var arrow = new PowiainaNum(arrow2);
1291
1370
  var t = this.clone();
1292
1371
  if (arrow.lt(0) || !arrow.isInt() || arrow.isNaN() || this.isNaN()) return function () {
1372
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1293
1373
  return PowiainaNum.NaN.clone();
1294
1374
  };
1295
1375
  if (arrow.eq(0)) return function (other) {
@@ -1304,9 +1384,13 @@
1304
1384
  var other = new PowiainaNum(other2);
1305
1385
  var r;
1306
1386
  if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
1307
- if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
1387
+ if (other.lt(PowiainaNum.ZERO)) {
1388
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1389
+ return PowiainaNum.NaN.clone();
1390
+ }
1308
1391
  if (t.eq(PowiainaNum.ZERO)) {
1309
1392
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
1393
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
1310
1394
  return PowiainaNum.NaN.clone();
1311
1395
  }
1312
1396
  if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
@@ -1495,7 +1579,8 @@
1495
1579
  /**
1496
1580
  * -1: `this` is smaller
1497
1581
  * 0: equals
1498
- * 1: `x` is bigger
1582
+ * 1: `x` is smaller
1583
+ * 2: NaN
1499
1584
  */
1500
1585
  }, {
1501
1586
  key: "compare",
@@ -1504,6 +1589,7 @@
1504
1589
  if (this.isNaN() || other.isNaN()) return 2;
1505
1590
  if (this.sign < other.sign) return -1;
1506
1591
  if (this.sign > other.sign) return 1;
1592
+ var t = this;
1507
1593
  //this.sign = other.sign
1508
1594
  var allneg = this.sign == -1 && other.sign == -1;
1509
1595
  if (this.small && !other.small) return -1 * (allneg ? -1 : 1);
@@ -1515,6 +1601,10 @@
1515
1601
  for (var i = 0; this.array.length - 1 - i >= 0 && other.array.length - 1 - i >= 0; i++) {
1516
1602
  var op1 = this.array[this.array.length - 1 - i];
1517
1603
  var op2 = other.array[other.array.length - 1 - i];
1604
+ if (op1.repeat === Infinity && op2.repeat === Infinity) {
1605
+ if (t.small === other.small) return 0;
1606
+ return other.small ? 1 : -1;
1607
+ }
1518
1608
  if (op1.repeat === Infinity) {
1519
1609
  result = 1;
1520
1610
  break;
@@ -2045,8 +2135,20 @@
2045
2135
  this.small = false;
2046
2136
  renormalize = true;
2047
2137
  }
2048
- // for any 10{X>9e15}10, replace into 10{!}X;
2049
- if (this.array.length >= 2 && this.array[1].arrow >= MSI) {
2138
+ // for any 10{!}^t x, replace to 10{!}^t-1 10{x}10
2139
+ if (this.array.length >= 2 && !isFinite(this.array[1].arrow)) {
2140
+ if (this.array[1].repeat > 1) {
2141
+ this.array.push(newOperator(this.array[1].repeat - 1, 1 / 0, this.array[1].expans, this.array[1].megota));
2142
+ this.array[1].repeat = 1;
2143
+ this.array[1].arrow = this.array[0].repeat;
2144
+ this.array[0].repeat = 10;
2145
+ } else {
2146
+ this.array[1].arrow = this.array[0].repeat;
2147
+ this.array[0].repeat = 10;
2148
+ }
2149
+ }
2150
+ // for any 10{X>9e15}10 finite, replace into 10{!}X;
2151
+ if (this.array.length >= 2 && this.array[1].arrow >= MSI && isFinite(this.array[1].arrow)) {
2050
2152
  this.array[0].repeat = this.array[1].arrow;
2051
2153
  this.array[1] = newOperator(1, Infinity, this.array[1].expans, this.array[1].megota);
2052
2154
  }
@@ -2072,16 +2174,6 @@
2072
2174
  x.array[0].repeat = 10;
2073
2175
  renormalize = true;
2074
2176
  }
2075
- if (x.array.length >= 2 && x.array[0].repeat < MSI && x.array[1].arrow >= 2 && x.array[1].repeat == 1 &&
2076
- //10^^^ 10
2077
- isFinite(x.array[1].arrow)) {
2078
- // for any 10{A sample=2}1e9, turn into (10{A-1})^1e9-1 10
2079
- // But dont convert when a is infinite
2080
- // [1e9, [R=1, A=2, sth, sth]]
2081
- x.array.splice(1, 1, newOperator(x.array[0].repeat - 1, x.array[1].arrow - 1, x.array[1].expans, x.array[1].megota));
2082
- x.array[0].repeat = 10;
2083
- renormalize = true;
2084
- }
2085
2177
  // for any (10{A=2})^1e16 10, turn into (10{A+1}) 1e16
2086
2178
  if (x.array.length >= 2 && x.array[1].repeat > MSI && x.array[1].arrow !== Infinity) {
2087
2179
  x.array[1].arrow++;
@@ -2455,13 +2547,19 @@
2455
2547
  if (base.eq(1)) return new PowiainaNum(1);
2456
2548
  if (power.eq(1)) return new PowiainaNum(base);
2457
2549
  if (power.isZero()) return new PowiainaNum(1);
2458
- if (base.lt(0)) return PowiainaNum.NaN.clone();
2550
+ if (base.lt(0)) {
2551
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
2552
+ return PowiainaNum.NaN.clone();
2553
+ }
2459
2554
  // // check infinite
2460
2555
  // let sufpowiaina = args.slice(4);
2461
2556
  // if (sufpowiaina.filter((f) => new PowiainaNum(f).gte(2)).length > 0) {
2462
2557
  // return PowiainaNum.POSITIVE_INFINITY;
2463
2558
  // }
2464
2559
  if (new PowiainaNum(powiaina2).gte(3)) return PowiainaNum.POSITIVE_INFINITY.clone();
2560
+ if (readArg(0).eq(0) && readArg(1).eq(1) && readArg(2).eq(1)) {
2561
+ return base.mul(power);
2562
+ }
2465
2563
  if (readArg(0).eq(1) && readArg(1).eq(1) && readArg(2).eq(1)) {
2466
2564
  return base.pow(power);
2467
2565
  }
@@ -2511,12 +2609,16 @@
2511
2609
  return x.toString();
2512
2610
  }
2513
2611
  function getMSIForm(arrow, expans, megota) {
2514
- return "10{".concat(infToBang(arrow), ",").concat(infToBang(expans), ",").concat(megota, "}").concat(MSI);
2612
+ var _convertOperator = convertOperator(arrow, expans, megota),
2613
+ _convertOperator2 = _slicedToArray(_convertOperator, 3),
2614
+ a = _convertOperator2[0],
2615
+ e = _convertOperator2[1],
2616
+ m = _convertOperator2[2];
2617
+ return "10{".concat(infToBang(a), ",").concat(infToBang(e), ",").concat(m, "}").concat(MSI);
2515
2618
  }
2516
2619
  var t = base.clone();
2517
2620
  var arrows = new PowiainaNum(readArg(0));
2518
2621
  var result = function (other2) {
2519
- var _r, _r2;
2520
2622
  var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2521
2623
  console.log("".concat("-".repeat(depth), " {").concat(base2, ",").concat(power2, ",").concat(arrow2, ",").concat(expans2, ",").concat(megota2, "}"));
2522
2624
  var other = new PowiainaNum(other2);
@@ -2525,21 +2627,26 @@
2525
2627
  if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
2526
2628
  if (t.eq(PowiainaNum.ZERO)) {
2527
2629
  if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
2630
+ if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
2528
2631
  return PowiainaNum.NaN.clone();
2529
2632
  }
2530
2633
  if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
2531
2634
  if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE.clone();
2532
2635
  if (other.eq(PowiainaNum.ONE)) return t.clone();
2533
2636
  if (arrows.eq(0)) {
2534
- return PowiainaNum.BEAF(t, t, power, expans.sub(1), megota, powiaina2, depth + 1);
2637
+ return PowiainaNum.BEAF_core(t, t, power, expans.sub(1), megota, powiaina2, depth + 1);
2535
2638
  // {this, this, power, expans-1, megota}
2536
2639
  }
2537
2640
  if (expans.eq(0)) {
2538
- return PowiainaNum.BEAF(t, t, t, power, megota.sub(1), powiaina2, depth + 1);
2641
+ return PowiainaNum.BEAF_core(t, t, t, power, megota.sub(1), powiaina2, depth + 1);
2539
2642
  // {this, this, this, power, megota-1}
2540
2643
  }
2541
2644
  if (megota.eq(0)) {
2542
- return PowiainaNum.BEAF(t, t, t, t, expans, new PowiainaNum(powiaina2).sub(1), depth + 1);
2645
+ return PowiainaNum.BEAF_core(t, t, t, t, expans, new PowiainaNum(powiaina2).sub(1), depth + 1);
2646
+ }
2647
+ // megota < 9e15, not implemented
2648
+ if (megota.gt(MSI)) {
2649
+ throw new Error("Not implemeneted");
2543
2650
  }
2544
2651
  // expans > 9e15, that using 10{?, x}, x=expans;
2545
2652
  if (expans.gt(MSI)) {
@@ -2556,15 +2663,17 @@
2556
2663
  var arrowsNum = arrows.toNumber();
2557
2664
  // arrow < 9e15
2558
2665
  // 10{x}2 = 10{x-1}10
2559
- if (other.eq(2)) return PowiainaNum.BEAF(t, t, arrowsNum - 1, expans, megota, powiaina2, depth + 1);
2666
+ if (other.eq(2)) return PowiainaNum.BEAF_core(t, t, arrowsNum - 1, expans, megota, powiaina2, depth + 1);
2560
2667
  if (t.max(other).gt(getMSIForm(arrowsNum + 1, expans.toNumber(), megota.toNumber()))) return t.max(other);
2561
- if (t.gt(getMSIForm(arrowsNum, expans.toNumber(), megota.toNumber())) || other.gt(MSI)) {
2668
+ // arrow < 9e15
2669
+ // 10{x}2 = 10{x-1}10
2670
+ if (t.gt(getMSIForm(arrowsNum + 1, expans.toNumber(), megota.toNumber())) || other.gt(MSI)) {
2562
2671
  if (t.gt(getMSIForm(arrowsNum, expans.toNumber(), megota.toNumber()))) {
2563
2672
  r = t.clone();
2564
2673
  r.setOperator(r.getOperator(arrowsNum, expans.toNumber(), megota.toNumber()) - 1, arrowsNum, expans.toNumber(), megota.toNumber());
2565
2674
  r.normalize();
2566
- } else if (t.gt(getMSIForm.apply(void 0, _toConsumableArray(convertOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber()))))) {
2567
- r = new PowiainaNum(t.getOperator.apply(t, _toConsumableArray(convertOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber()))));
2675
+ } else if (t.gt(getMSIForm(arrowsNum - 1, expans.toNumber(), megota.toNumber()))) {
2676
+ r = new PowiainaNum(t.getOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber()));
2568
2677
  } else {
2569
2678
  r = PowiainaNum.ZERO;
2570
2679
  }
@@ -2584,17 +2693,114 @@
2584
2693
  var y = other.toNumber();
2585
2694
  var f = Math.floor(y);
2586
2695
  var arrows_m1 = arrows.sub(PowiainaNum.ONE);
2587
- r = PowiainaNum.BEAF(t, y - f, arrows_m1.toNumber(), expans, megota, powiaina2, depth + 1);
2696
+ r = PowiainaNum.BEAF_core(t, y - f, arrows_m1, expans, megota, powiaina, depth + 1);
2697
+ // r = t.arrow(arrows_m1)(y - f, payload, depth + 1);
2588
2698
  var i = 0;
2589
- for (var m = new PowiainaNum(getMSIForm.apply(void 0, _toConsumableArray(convertOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber())))); f !== 0 && r.lt(m) && i < 100; i++) {
2699
+ for (var m = getMSIForm(arrowsNum - 1, expans.toNumber(), megota.toNumber()); f !== 0 && r.lt(m) && i < 100; i++) {
2590
2700
  if (f > 0) {
2591
- r = PowiainaNum.BEAF(base, r, arrows_m1.toNumber(), expans, megota, powiaina2, depth + 1);
2701
+ r = PowiainaNum.BEAF_core(t, r, arrows_m1, expans, megota, powiaina, depth + 1);
2592
2702
  --f;
2593
2703
  }
2594
2704
  }
2595
2705
  if (i == 100) f = 0;
2596
- (_r = r).setOperator.apply(_r, [(_r2 = r).getOperator.apply(_r2, _toConsumableArray(convertOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber()))) + f].concat(_toConsumableArray(convertOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber()))));
2706
+ r.setOperator(r.getOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber()) + f, arrowsNum - 1, expans.toNumber(), megota.toNumber());
2597
2707
  r.normalize();
2708
+ // if (
2709
+ // t.gt(getMSIForm(arrowsNum, expans.toNumber(), megota.toNumber())) ||
2710
+ // other.gt(MSI)
2711
+ // ) {
2712
+ // if (t.gt(getMSIForm(arrowsNum, expans.toNumber(), megota.toNumber()))) {
2713
+ // r = t.clone();
2714
+ // r.setOperator(
2715
+ // r.getOperator(arrowsNum, expans.toNumber(), megota.toNumber()) - 1,
2716
+ // arrowsNum,
2717
+ // expans.toNumber(),
2718
+ // megota.toNumber()
2719
+ // );
2720
+ // r.normalize();
2721
+ // } else if (
2722
+ // t.gt(
2723
+ // getMSIForm(
2724
+ // ...convertOperator(
2725
+ // arrowsNum - 1,
2726
+ // expans.toNumber(),
2727
+ // megota.toNumber()
2728
+ // )
2729
+ // )
2730
+ // )
2731
+ // ) {
2732
+ // r = new PowiainaNum(
2733
+ // t.getOperator(
2734
+ // ...convertOperator(
2735
+ // arrowsNum - 1,
2736
+ // expans.toNumber(),
2737
+ // megota.toNumber()
2738
+ // )
2739
+ // )
2740
+ // );
2741
+ // } else {
2742
+ // r = PowiainaNum.ZERO;
2743
+ // }
2744
+ // const j = r.add(other);
2745
+ // j.setOperator(
2746
+ // j.getOperator(arrowsNum, expans.toNumber(), megota.toNumber()) + 1,
2747
+ // arrowsNum,
2748
+ // expans.toNumber(),
2749
+ // megota.toNumber()
2750
+ // );
2751
+ // j.normalize();
2752
+ // return j;
2753
+ // }
2754
+ // const y = other.toNumber();
2755
+ // let f = Math.floor(y);
2756
+ // const arrows_m1 = arrows.sub(PowiainaNum.ONE);
2757
+ // r = PowiainaNum.BEAF(
2758
+ // t,
2759
+ // y - f,
2760
+ // arrows_m1.toNumber(),
2761
+ // expans,
2762
+ // megota,
2763
+ // powiaina2,
2764
+ // depth + 1
2765
+ // );
2766
+ // let i = 0;
2767
+ // for (
2768
+ // const m = new PowiainaNum(
2769
+ // getMSIForm(
2770
+ // ...convertOperator(
2771
+ // arrowsNum - 1,
2772
+ // expans.toNumber(),
2773
+ // megota.toNumber()
2774
+ // )
2775
+ // )
2776
+ // );
2777
+ // f !== 0 && r.lt(m) && i < 100;
2778
+ // i++
2779
+ // ) {
2780
+ // if (f > 0) {
2781
+ // r = PowiainaNum.BEAF(
2782
+ // base,
2783
+ // r,
2784
+ // arrows_m1.toNumber(),
2785
+ // expans,
2786
+ // megota,
2787
+ // powiaina2,
2788
+ // depth + 1
2789
+ // );
2790
+ // --f;
2791
+ // }
2792
+ // }
2793
+ // if (i == 100) f = 0;
2794
+ // r.setOperator(
2795
+ // r.getOperator(
2796
+ // ...convertOperator(
2797
+ // arrowsNum - 1,
2798
+ // expans.toNumber(),
2799
+ // megota.toNumber()
2800
+ // )
2801
+ // ) + f,
2802
+ // ...convertOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber())
2803
+ // );
2598
2804
  return r;
2599
2805
  }(power, depth);
2600
2806
  console.log("".concat("-".repeat(depth), " = ").concat(result));
@@ -2746,7 +2952,7 @@
2746
2952
  }, {
2747
2953
  key: "fromNumber",
2748
2954
  value: function fromNumber(x) {
2749
- var obj = new PowiainaNum(); // NaN
2955
+ var obj = new PowiainaNum();
2750
2956
  obj.resetFromObject({
2751
2957
  array: [{
2752
2958
  arrow: 0,
@@ -2758,6 +2964,7 @@
2758
2964
  layer: 0,
2759
2965
  sign: 0
2760
2966
  });
2967
+ if (Number.isNaN(x)) return obj;
2761
2968
  if (x < 0) obj.sign = -1; // negative
2762
2969
  else if (x == 0) {
2763
2970
  obj.sign = 0;
@@ -3304,13 +3511,18 @@
3304
3511
  PowiainaNum.arrowFuncMap = new Map();
3305
3512
  //#region configurations
3306
3513
  /**
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.
3514
+ * If you set this config to true,
3515
+ * 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
3516
  */
3309
- PowiainaNum.usingBreakEternityLikeFromString = false;
3517
+ PowiainaNum.usingBreakEternityLikeFromString = true;
3310
3518
  /**
3311
3519
  * If you set this config to true, the `constructor` method will return Zero instead of NaN when call new PowiainaNum() with no arguments.
3312
3520
  */
3313
3521
  PowiainaNum.blankArgumentConstructorReturnZero = false;
3522
+ /**
3523
+ * If you set this config to true, when calucation returns NaN, the program will throw error.
3524
+ */
3525
+ PowiainaNum.throwErrorOnResultNaN = false;
3314
3526
 
3315
3527
  exports.arraySortFunction = arraySortFunction;
3316
3528
  exports["default"] = PowiainaNum;