powiaina_num.js 0.2.10 → 0.2.11

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.
@@ -68,8 +68,6 @@
68
68
 
69
69
  /* Author: VeryrrDefine 0.2.0-beta.1.1*/
70
70
  var _a;
71
- //#endregion
72
- //#region constants
73
71
  var powiainaNumError = "[PowiainaNum 0.2 error]";
74
72
  var MSI = 9007199254740991;
75
73
  var MSI_LOG10 = 15.954589770191003;
@@ -77,8 +75,6 @@
77
75
  var LONG_STRING_MIN_LENGTH = 17;
78
76
  var EXP_E_REC = 1.444667861009766;
79
77
  var isPowiainaNum = /^(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+))$/;
80
- var BE_REGEX = /^((\d+(\.\d*)?|\d*\.\d+)?([EeFf]([-\+]?)))*(0|\d+(\.\d*)?|\d*\.\d+)$/;
81
- //#endregion
82
78
  //#region some useful functions
83
79
  function newOperator(r) {
84
80
  var a = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
@@ -92,29 +88,6 @@
92
88
  valuereplaced: a == Infinity ? 0 : e == Infinity ? 1 : -1
93
89
  };
94
90
  }
95
- function removeCommasOutsideBraces(input) {
96
- var result = "";
97
- var inBraces = false;
98
- for (var i = 0; i < input.length; i++) {
99
- var _char = input[i];
100
- if (_char === "{") {
101
- inBraces = true;
102
- result += _char;
103
- } else if (_char === "}") {
104
- inBraces = false;
105
- result += _char;
106
- } else if (_char === ",") {
107
- // 只有在花括号内部才保留逗号
108
- if (inBraces) {
109
- result += _char;
110
- }
111
- // 如果在花括号外部,就不添加到结果中(相当于删除)
112
- } else {
113
- result += _char;
114
- }
115
- }
116
- return result;
117
- }
118
91
  // parse 0.1.x PowiainaNum.js string
119
92
  function parseLegacyPowiainaNumString(str) {
120
93
  var pattern = /l(\d+)\s+s(\d+)\s+a(\[.*\])/;
@@ -147,7 +120,7 @@
147
120
  function replaceETo10(str) {
148
121
  // 使用正则表达式匹配 (e^数字) 的模式
149
122
  // 正则解释:\(e\^(\d+)\) 匹配 (e^数字),其中 \d+ 匹配一个或多个数字
150
- return str.replace(/\(e\^(\d+)\)/g, "(10^)^$1 ").replace(/(\d+)[Pp][Tt]/g, "(10^)^$1 ");
123
+ return str.replace(/\(e\^(\d+)\)/g, "(10^)^$1 ").replace(/(\d+)\x20*PT/g, "(10^)^$1 ");
151
124
  }
152
125
  /**
153
126
  * 把一个字符串很长的数进行以10为底的对数
@@ -201,10 +174,8 @@
201
174
  // The evaluation can become inaccurate very close to the branch point
202
175
  // Evaluates W(x, 0) if principal is true, W(x, -1) if principal is false
203
176
  function f_lambertw(z) {
204
- var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e-10;
205
- var pr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
206
- var tol = t;
207
- var principal = pr;
177
+ var tol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e-10;
178
+ var principal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
208
179
  var w;
209
180
  var wn;
210
181
  if (!Number.isFinite(z)) {
@@ -367,26 +338,16 @@
367
338
  this.small = false;
368
339
  this.sign = 0;
369
340
  this.layer = 0;
370
- if (PowiainaNum.blankArgumentConstructorReturnZero) {
371
- this.resetFromObject(PowiainaNum.ZERO);
372
- }
373
- try {
374
- if (typeof arg1 == "undefined") {} else if (typeof arg1 == "number") {
375
- var obj = PowiainaNum.fromNumber(arg1);
376
- this.resetFromObject(obj);
377
- } else if (_typeof(arg1) == "object") {
378
- var _obj = PowiainaNum.fromObject(arg1);
379
- this.resetFromObject(_obj);
380
- } else if (typeof arg1 == "string") {
381
- var _obj2 = PowiainaNum.fromString(arg1);
382
- this.resetFromObject(_obj2);
383
- } else {
384
- var isn = arg1;
385
- }
386
- } catch (e) {
387
- console.error("Malformed input");
388
- console.error(e);
389
- }
341
+ if (typeof arg1 == "undefined") ; else if (typeof arg1 == "number") {
342
+ var obj = PowiainaNum.fromNumber(arg1);
343
+ this.resetFromObject(obj);
344
+ } else if (_typeof(arg1) == "object") {
345
+ var _obj = PowiainaNum.fromObject(arg1);
346
+ this.resetFromObject(_obj);
347
+ } else if (typeof arg1 == "string") {
348
+ var _obj2 = PowiainaNum.fromString(arg1);
349
+ this.resetFromObject(_obj2);
350
+ } else ;
390
351
  }
391
352
  //#region 4 Basic calculates.
392
353
  /**
@@ -397,7 +358,7 @@
397
358
  key: "add",
398
359
  value: function add(other) {
399
360
  var _b, _c, _d, _e;
400
- var x = this.clone().normalize();
361
+ var x = this.clone();
401
362
  var y = new PowiainaNum(other);
402
363
  // inf + -inf = nan
403
364
  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();
@@ -458,7 +419,7 @@
458
419
  mult *= -1;
459
420
  }
460
421
  if (t == 0) throw Error("Encounter a calculate error");
461
- r = PowiainaNum.NaN.clone();
422
+ r = new PowiainaNum();
462
423
  r.sign = 1;
463
424
  if (l > MSI_LOG10 || l < -MSI_LOG10) {
464
425
  r.array = [newOperator(l, 0), newOperator(1, 1)];
@@ -469,21 +430,11 @@
469
430
  r.sign *= mult;
470
431
  return r;
471
432
  }
472
- }, {
473
- key: "plus",
474
- value: function plus(other) {
475
- return this.add(other);
476
- }
477
433
  }, {
478
434
  key: "sub",
479
435
  value: function sub(a) {
480
436
  return this.add(new PowiainaNum(a).neg());
481
437
  }
482
- }, {
483
- key: "minus",
484
- value: function minus(other) {
485
- return this.sub(other);
486
- }
487
438
  }, {
488
439
  key: "mul",
489
440
  value: function mul(other) {
@@ -517,22 +468,12 @@
517
468
  r.sign = x.sign * y.sign;
518
469
  return r;
519
470
  }
520
- }, {
521
- key: "times",
522
- value: function times(other) {
523
- return this.mul(other);
524
- }
525
471
  }, {
526
472
  key: "div",
527
473
  value: function div(other) {
528
474
  var x = new PowiainaNum(other).rec();
529
475
  return this.mul(x);
530
476
  }
531
- }, {
532
- key: "divide",
533
- value: function divide(other) {
534
- return this.div(other);
535
- }
536
477
  }, {
537
478
  key: "mod",
538
479
  value: function mod(x) {
@@ -540,20 +481,14 @@
540
481
  var division = this.div(other);
541
482
  return division.sub(division.floor()).mul(other);
542
483
  }
543
- }, {
544
- key: "modulus",
545
- value: function modulus(x) {
546
- return this.mod(x);
547
- }
548
- }, {
549
- key: "pow10",
550
- value:
551
484
  //#endregion
552
485
  //#region power
553
486
  /**
554
487
  * @returns 10 to the power of `this`
555
488
  */
556
- function pow10() {
489
+ }, {
490
+ key: "pow10",
491
+ value: function pow10() {
557
492
  var _b, _c;
558
493
  var r = this.clone();
559
494
  // inf & nan check
@@ -583,16 +518,8 @@
583
518
  if (!other.isFinite()) return other.clone();
584
519
  if (!this.isFinite()) return this.clone();
585
520
  if (this.eq(10)) return other.pow10();
586
- if (other.isneg()) return this.pow(other.neg()).rec();
587
521
  if (this.isneg()) {
588
- if (!other.isInt()) {
589
- if (other.small) {
590
- if (other.rec().div(2).eq(1)) {
591
- return this.neg().pow(other).neg();
592
- }
593
- }
594
- return PowiainaNum.NaN.clone();
595
- }
522
+ if (!other.isInt()) return PowiainaNum.NaN.clone();
596
523
  var r = this.abs().pow(other);
597
524
  r.sign = function () {
598
525
  var a = other.mod(2).round();
@@ -669,16 +596,6 @@
669
596
  var other = new PowiainaNum(base);
670
597
  return this.log10().div(other.log10());
671
598
  }
672
- }, {
673
- key: "log2",
674
- value: function log2() {
675
- return this.log(2);
676
- }
677
- }, {
678
- key: "logBase",
679
- value: function logBase(a) {
680
- return this.log(a);
681
- }
682
599
  }, {
683
600
  key: "ln",
684
601
  value: function ln() {
@@ -786,8 +703,7 @@
786
703
  //Code from break_eternity.js
787
704
  //Some special values, for testing: https://en.wikipedia.org/wiki/Lambert_W_function#Special_values
788
705
  function lambertw() {
789
- var princ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
790
- var principal = princ;
706
+ var principal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
791
707
  if (this.lt(-0.3678794411710499)) {
792
708
  return PowiainaNum.NaN.clone(); //complex
793
709
  } else if (principal) {
@@ -805,9 +721,9 @@
805
721
  if (this.sign === 1) {
806
722
  return PowiainaNum.NaN.clone(); //complex
807
723
  }
808
- if (this.lt(9e15)) {
724
+ if (this.layer === 0) {
809
725
  return PowiainaNum.fromNumber(f_lambertw(this.sign * this.array[0].repeat, 1e-10, false));
810
- } else if (this.lt(PowiainaNum.E_MSI)) {
726
+ } else if (this.layer == 1) {
811
727
  return d_lambertw(this, 1e-10, false);
812
728
  } else {
813
729
  return this.neg().rec().lambertw().neg();
@@ -828,9 +744,7 @@
828
744
  var payl = new PowiainaNum(payload);
829
745
  if (t.isNaN() || other.isNaN() || payl.isNaN()) return PowiainaNum.NaN.clone();
830
746
  if (t.eq(1)) return PowiainaNum.ONE.clone();
831
- if (payl.neq(PowiainaNum.ONE) && t.gte(EXP_E_REC)) {
832
- other = other.add(payl.slog(t));
833
- }
747
+ if (payl.neq(PowiainaNum.ONE)) other = other.add(payl.slog(t));
834
748
  var negln;
835
749
  if (other.isInfi() && other.sign > 0) {
836
750
  if (t.gte(EXP_E_REC)) return PowiainaNum.POSITIVE_INFINITY.clone();
@@ -1160,9 +1074,9 @@
1160
1074
  // base^base^... = x? (? bases)
1161
1075
  var r = 0;
1162
1076
  // 计算x与base的差距
1163
- var distanceLayerOf = x.getOperator(arrowsNum) - b.getOperator(arrowsNum);
1164
- if (distanceLayerOf > 3) {
1165
- var l = distanceLayerOf - 3;
1077
+ var t = x.getOperator(arrowsNum) - b.getOperator(arrowsNum);
1078
+ if (t > 3) {
1079
+ var l = t - 3;
1166
1080
  r += l;
1167
1081
  x.setOperator(x.getOperator(arrowsNum) - l, arrowsNum);
1168
1082
  }
@@ -1204,18 +1118,18 @@
1204
1118
  }
1205
1119
  }, {
1206
1120
  key: "pentate",
1207
- value: function pentate(other, payload) {
1208
- return this.arrow(3)(other, payload);
1121
+ value: function pentate(other) {
1122
+ return this.arrow(3)(other);
1209
1123
  }
1210
1124
  }, {
1211
1125
  key: "hexate",
1212
- value: function hexate(other, payload) {
1213
- return this.arrow(4)(other, payload);
1126
+ value: function hexate(other) {
1127
+ return this.arrow(4)(other);
1214
1128
  }
1215
1129
  }, {
1216
1130
  key: "pent",
1217
- value: function pent(other, payload) {
1218
- return this.arrow(3)(other, payload);
1131
+ value: function pent(other) {
1132
+ return this.arrow(3)(other);
1219
1133
  }
1220
1134
  }, {
1221
1135
  key: "penta_log",
@@ -1223,9 +1137,6 @@
1223
1137
  var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
1224
1138
  return this.anyarrow_log(3)(base);
1225
1139
  }
1226
- }, {
1227
- key: "expansion",
1228
- value:
1229
1140
  /**
1230
1141
  * Expansion, which is `this`{{1}}`other2`.
1231
1142
  *
@@ -1233,7 +1144,9 @@
1233
1144
  *
1234
1145
  * @url https://googology.fandom.com/wiki/Expansion
1235
1146
  */
1236
- function expansion(other2) {
1147
+ }, {
1148
+ key: "expansion",
1149
+ value: function expansion(other2) {
1237
1150
  var other = new PowiainaNum(other2);
1238
1151
  var t = this.clone();
1239
1152
  if (other.lt(PowiainaNum.ZERO) || !other.isInt()) return PowiainaNum.NaN.clone();
@@ -1546,16 +1459,6 @@
1546
1459
  var t = this.cmp(other);
1547
1460
  return t == 0 || t == 1;
1548
1461
  }
1549
- }, {
1550
- key: "equals",
1551
- value: function equals(other) {
1552
- return this.eq(other);
1553
- }
1554
- }, {
1555
- key: "notEquals",
1556
- value: function notEquals(other) {
1557
- return this.neq(other);
1558
- }
1559
1462
  }, {
1560
1463
  key: "eq_tolerance",
1561
1464
  value: function eq_tolerance(value) {
@@ -1617,16 +1520,6 @@
1617
1520
  a.small = !a.small;
1618
1521
  return a;
1619
1522
  }
1620
- }, {
1621
- key: "recip",
1622
- value: function recip() {
1623
- return this.rec();
1624
- }
1625
- }, {
1626
- key: "reciprocate",
1627
- value: function reciprocate() {
1628
- return this.rec();
1629
- }
1630
1523
  }, {
1631
1524
  key: "floor",
1632
1525
  value: function floor() {
@@ -1667,9 +1560,6 @@
1667
1560
  r.sign = this.sign;
1668
1561
  return r;
1669
1562
  }
1670
- }, {
1671
- key: "trunc",
1672
- value:
1673
1563
  /**
1674
1564
  * Work like `Math.trunc`,
1675
1565
  *
@@ -1682,10 +1572,15 @@
1682
1572
  * new PowiainaNum(-1.114514).trunc() == new PowiainaNum(-1)
1683
1573
  * @returns
1684
1574
  */
1685
- function trunc() {
1575
+ }, {
1576
+ key: "trunc",
1577
+ value: function trunc() {
1686
1578
  var y = this.clone();
1687
1579
  return y.gte(0) ? y.floor() : y.ceil();
1688
1580
  }
1581
+ /**
1582
+ * @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
1583
+ */
1689
1584
  }, {
1690
1585
  key: "isNaN",
1691
1586
  value: function (_isNaN) {
@@ -1748,164 +1643,10 @@
1748
1643
  value: function isneg() {
1749
1644
  return this.sign < 0;
1750
1645
  }
1751
- }, {
1752
- key: "getOperatorIndex",
1753
- value:
1754
- //#endregion
1755
- //#region operators
1756
- /**
1757
- * @returns number will return the index of the operator in array. return as x.5 if it's between the xth and x+1th operators.
1758
- */
1759
- function getOperatorIndex(arrow) {
1760
- var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1761
- var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1762
- for (var i = 0; i < this.array.length; i++) {
1763
- var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
1764
- if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
1765
- if (cmp == 1) return i - 0.5; // It's between [xx, xx,xx*,?,*xx]!
1766
- }
1767
- return this.array.length - 0.5;
1768
- }
1769
- /**
1770
- * @returns number repeats of operators with given arguments.
1771
- */
1772
- }, {
1773
- key: "getOperator",
1774
- value: function getOperator(arrow) {
1775
- var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1776
- var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1777
- var index = this.getOperatorIndex(arrow, expans, megota);
1778
- if (!this.array[index]) return 0;
1779
- return this.array[index].repeat;
1780
- }
1781
- /**
1782
- * Modify the repeat of operator
1783
- * @param number val the repeat of operator will modify to array.
1784
- * @returns bool Is the operators array changed?
1785
- */
1786
- }, {
1787
- key: "setOperator",
1788
- value: function setOperator(val, arrow) {
1789
- var expans = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1790
- var megota = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
1791
- // if (arrow!=0&&val==0) return false;
1792
- var index = this.getOperatorIndex(arrow, expans, megota);
1793
- if (!this.array[index]) {
1794
- this.array.splice(Math.ceil(index), 0, {
1795
- arrow: arrow,
1796
- expans: expans,
1797
- megota: megota,
1798
- valuereplaced: expans === Infinity ? 1 : arrow == Infinity ? 0 : -1,
1799
- repeat: val
1800
- });
1801
- return true;
1802
- }
1803
- this.array[index].repeat = val;
1804
- // this.normalize()
1805
- return false;
1806
- }
1807
- //#endregion
1808
- //#region converters
1809
- /**
1810
- * Convert `this` to Javascript `number`
1811
- *
1812
- * returns `Infinity` when the number is greater than `Number.MAX_VALUE`
1813
- */
1814
- }, {
1815
- key: "toNumber",
1816
- value: function toNumber() {
1817
- if (this.sign == -1) return -this.neg().toNumber();
1818
- if (this.small) return 1 / this.rec().toNumber();
1819
- if (this.array.length > 2) return Infinity;
1820
- if (this.array.length == 1) return this.array[0].repeat;else if (this.array.length == 2 && this.array[1].arrow == 1 && this.array[1].expans == 1 && this.array[1].megota == 1 && this.array[1].repeat == 1) return Math.pow(10, this.getOperator(0));
1821
- return NaN;
1822
- }
1823
- /**
1824
- * Convert `this` to a string
1825
- */
1826
- }, {
1827
- key: "toString_core",
1828
- value: function toString_core() {
1829
- if (this.isNaN()) return "NaN";
1830
- if (this.sign == -1) return "-".concat(this.neg().toString());
1831
- if (this.small) {
1832
- if (this.isZero()) return "0";
1833
- return "/".concat(this.rec().toString());
1834
- }
1835
- if (this.isInfi()) return "Infinity";
1836
- // P^a (10{arrow,expans,megota})^repeation base
1837
- var res = "";
1838
- if (!this.layer) res += "";else if (this.layer < 3) res += "P".repeat(this.layer);else res += "P^" + this.layer + " ";
1839
- for (var i = this.array.length - 1; i >= 0; i--) {
1840
- var oper = this.array[i];
1841
- var calc = "10{".concat(oper.arrow === Infinity ? "!" : oper.arrow).concat(oper.expans > 1 || oper.megota > 1 ? ",".concat(oper.expans === Infinity ? "!" : oper.expans) : "").concat(oper.megota > 1 ? ",".concat(oper.megota) : "", "}");
1842
- if (oper.arrow == 1 && oper.expans == 1 && oper.megota == 1 && oper.repeat < 5) {
1843
- calc = "e".repeat(oper.repeat);
1844
- } else if (oper.arrow == 0 && oper.expans == 1 && oper.megota == 1) {
1845
- calc = oper.repeat.toString();
1846
- } else if (oper.repeat > 1) {
1847
- calc = "(".concat(calc, ")^").concat(oper.repeat, " ");
1848
- } else {
1849
- calc = "".concat(calc);
1850
- }
1851
- res += "".concat(calc);
1852
- }
1853
- return res;
1854
- }
1855
- }, {
1856
- key: "toString",
1857
- value: function toString() {
1858
- try {
1859
- return this.toString_core();
1860
- } catch (_b) {
1861
- console.error("Checked error when converting to string");
1862
- return "NaN";
1863
- }
1864
- }
1865
- }, {
1866
- key: "toJSON",
1867
- value:
1868
- /**
1869
- * Convert `this` to a JSON object
1870
- * @returns a JSON object
1871
- */
1872
- function toJSON() {
1873
- return "PN" + this.toString();
1874
- }
1875
- }, {
1876
- key: "arr01",
1877
- get:
1878
- /**
1879
- * A property array value for version 0.1.x PowiainaNum.
1880
- */
1881
- function get() {
1882
- var res = [0];
1883
- for (var i = 0; i < this.array.length; i++) {
1884
- if (i == 0) res[0] = this.array[i].repeat;else {
1885
- // @ts-ignore
1886
- res[i] = [0, 0, 0, 0];
1887
- // @ts-ignore
1888
- res[i][0] = this.array[i].arrow == Infinity ? "x" : this.array[i].arrow;
1889
- // @ts-ignore
1890
- res[i][1] = this.array[i].repeat;
1891
- // @ts-ignore
1892
- res[i][2] = this.array[i].expans == Infinity ? "x" : this.array[i].expans;
1893
- // @ts-ignore
1894
- res[i][3] = this.array[i].megota;
1895
- }
1896
- }
1897
- return res;
1898
- }
1899
- //#endregion
1900
- //#region useless functions
1901
- /**
1902
- * This function is for NaNe308, if you want to calculate G(x), use this function directly.
1903
- */
1904
1646
  }, {
1905
1647
  key: "normalize",
1906
1648
  value:
1907
1649
  //#endregion
1908
- //#region other functions
1909
1650
  /**
1910
1651
  * Normalize functions will make this number convert into standard format.(it also change `this`, like [].sort)
1911
1652
  * @returns normalized number
@@ -1914,14 +1655,9 @@
1914
1655
  //TODO: normalize
1915
1656
  var renormalize = true;
1916
1657
  var x = this;
1917
- if (this.array === undefined) {
1918
- x.array = [newOperator(NaN, 0, 1, 1)];
1919
- }
1920
- if (this.sign === undefined) this.sign = 0;
1921
- if (this.layer === undefined) this.layer = 0;
1922
- for (var i = 0; i < this.array.length; i++) {
1658
+ for (var _i = 0; _i < this.array.length; _i++) {
1923
1659
  // Check what is infinity
1924
- if (this.array[i].repeat == Infinity) {
1660
+ if (this.array[_i].repeat == Infinity) {
1925
1661
  this.array = [{
1926
1662
  arrow: 0,
1927
1663
  expans: 1,
@@ -1932,8 +1668,8 @@
1932
1668
  return this;
1933
1669
  }
1934
1670
  }
1935
- for (var _i = 1; _i < x.array.length; ++_i) {
1936
- var e = x.array[_i];
1671
+ for (var i = 1; i < x.array.length; ++i) {
1672
+ var e = x.array[i];
1937
1673
  if (e.arrow === null || e.arrow === undefined) {
1938
1674
  e.arrow = 0;
1939
1675
  }
@@ -1964,28 +1700,28 @@
1964
1700
  renormalize = false;
1965
1701
  // Sort arrays.
1966
1702
  this.array.sort(arraySortFunction);
1967
- for (var _i2 = 1; _i2 < x.array.length - 1; ++_i2) {
1968
- if (x.array[_i2].arrow == x.array[_i2 + 1].arrow && x.array[_i2].expans == x.array[_i2 + 1].expans && x.array[_i2].megota == x.array[_i2 + 1].megota) {
1703
+ for (i = 1; i < x.array.length - 1; ++i) {
1704
+ if (x.array[i].arrow == x.array[i + 1].arrow && x.array[i].expans == x.array[i + 1].expans && x.array[i].megota == x.array[i + 1].megota) {
1969
1705
  // same array's merge
1970
- x.array[_i2].repeat += x.array[_i2 + 1].repeat;
1971
- x.array.splice(_i2 + 1, 1);
1972
- --_i2;
1706
+ x.array[i].repeat += x.array[i + 1].repeat;
1707
+ x.array.splice(i + 1, 1);
1708
+ --i;
1973
1709
  renormalize = true;
1974
1710
  }
1975
1711
  }
1976
- for (var _i3 = 1; _i3 < x.array.length; ++_i3) {
1712
+ for (i = 1; i < x.array.length; ++i) {
1977
1713
  // If there is a 0 repeat operator, remove it.
1978
- if (x.array[_i3].arrow !== 0 && (x.array[_i3].repeat === 0 || x.array[_i3].repeat === null || x.array[_i3].repeat === undefined)) {
1979
- x.array.splice(_i3, 1);
1980
- --_i3;
1714
+ if (x.array[i].arrow !== 0 && (x.array[i].repeat === 0 || x.array[i].repeat === null || x.array[i].repeat === undefined)) {
1715
+ x.array.splice(i, 1);
1716
+ --i;
1981
1717
  continue;
1982
1718
  }
1983
1719
  // If there is a operator which arrow 0 and brace count >=2
1984
1720
  // replace it as arrow replacement operaotr
1985
- if (x.array[_i3].arrow == 0 && x.array[_i3].expans >= 2) {
1986
- x.array[_i3].arrow = Infinity;
1987
- x.array[_i3].valuereplaced = 0;
1988
- x.array[_i3].expans = x.array[_i3].expans - 1;
1721
+ if (x.array[i].arrow == 0 && x.array[i].expans >= 2) {
1722
+ x.array[i].arrow = Infinity;
1723
+ x.array[i].valuereplaced = 0;
1724
+ x.array[i].expans = x.array[i].expans - 1;
1989
1725
  }
1990
1726
  }
1991
1727
  if (x.array.length > PowiainaNum.maxOps) x.array.splice(1, x.array.length - PowiainaNum.maxOps); // max operators check
@@ -2015,11 +1751,6 @@
2015
1751
  this.small = !this.small;
2016
1752
  renormalize = true;
2017
1753
  }
2018
- // for a = 1, small should false.
2019
- if (this.array.length == 1 && this.array[0].repeat == 1 && this.small) {
2020
- this.small = false;
2021
- renormalize = true;
2022
- }
2023
1754
  // for any 10{X>9e15}10, replace into 10{!}X;
2024
1755
  if (this.array.length >= 2 && this.array[1].arrow >= MSI) {
2025
1756
  this.array[0].repeat = this.array[1].arrow;
@@ -2075,6 +1806,61 @@
2075
1806
  } while (renormalize);
2076
1807
  return this;
2077
1808
  }
1809
+ //#region operators
1810
+ /**
1811
+ * @returns number will return the index of the operator in array. return as x.5 if it's between the xth and x+1th operators.
1812
+ */
1813
+ }, {
1814
+ key: "getOperatorIndex",
1815
+ value: function getOperatorIndex(arrow) {
1816
+ var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1817
+ var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1818
+ for (var i = 0; i < this.array.length; i++) {
1819
+ var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
1820
+ if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
1821
+ if (cmp == 1) return i - 0.5; // It's between [xx, xx,xx*,?,*xx]!
1822
+ }
1823
+ return this.array.length - 0.5;
1824
+ }
1825
+ /**
1826
+ * @returns number repeats of operators with given arguments.
1827
+ */
1828
+ }, {
1829
+ key: "getOperator",
1830
+ value: function getOperator(arrow) {
1831
+ var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1832
+ var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1833
+ var index = this.getOperatorIndex(arrow, expans, megota);
1834
+ if (!this.array[index]) return 0;
1835
+ return this.array[index].repeat;
1836
+ }
1837
+ /**
1838
+ * Modify the repeat of operator
1839
+ * @param number val the repeat of operator will modify to array.
1840
+ * @returns bool Is the operators array changed?
1841
+ */
1842
+ }, {
1843
+ key: "setOperator",
1844
+ value: function setOperator(val, arrow) {
1845
+ var expans = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
1846
+ var megota = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
1847
+ // if (arrow!=0&&val==0) return false;
1848
+ var index = this.getOperatorIndex(arrow, expans, megota);
1849
+ if (!this.array[index]) {
1850
+ this.array.splice(Math.ceil(index), 0, {
1851
+ arrow: arrow,
1852
+ expans: expans,
1853
+ megota: megota,
1854
+ valuereplaced: expans === Infinity ? 1 : arrow == Infinity ? 0 : -1,
1855
+ repeat: val
1856
+ });
1857
+ return true;
1858
+ }
1859
+ this.array[index].repeat = val;
1860
+ // this.normalize()
1861
+ return false;
1862
+ }
1863
+ //#endregion
2078
1864
  /**
2079
1865
  * @returns a PowiainaNum object which deep copied from `this` object.
2080
1866
  */
@@ -2093,9 +1879,6 @@
2093
1879
  }, {
2094
1880
  key: "resetFromObject",
2095
1881
  value: function resetFromObject(powlikeObject) {
2096
- if (!powlikeObject.array) {
2097
- return;
2098
- }
2099
1882
  this.array = [];
2100
1883
  for (var i = 0; i < powlikeObject.array.length; i++) {
2101
1884
  this.array[i] = {
@@ -2111,56 +1894,107 @@
2111
1894
  this.layer = powlikeObject.layer;
2112
1895
  return this;
2113
1896
  }
1897
+ //#region converters
1898
+ /**
1899
+ * Convert `this` to Javascript `number`
1900
+ *
1901
+ * returns `Infinity` when the number is greater than `Number.MAX_VALUE`
1902
+ */
1903
+ }, {
1904
+ key: "toNumber",
1905
+ value: function toNumber() {
1906
+ if (this.sign == -1) return -this.neg().toNumber();
1907
+ if (this.small) return 1 / this.rec().toNumber();
1908
+ if (this.array.length > 2) return Infinity;
1909
+ if (this.array.length == 1) return this.array[0].repeat;else if (this.array.length == 2 && this.array[1].arrow == 1 && this.array[1].expans == 1 && this.array[1].megota == 1 && this.array[1].repeat == 1) return Math.pow(10, this.getOperator(0));
1910
+ return NaN;
1911
+ }
1912
+ /**
1913
+ * Convert `this` to a string
1914
+ */
1915
+ }, {
1916
+ key: "toString",
1917
+ value: function toString() {
1918
+ if (this.isNaN()) return "NaN";
1919
+ if (this.sign == -1) return "-".concat(this.neg().toString());
1920
+ if (this.small) {
1921
+ if (this.isZero()) return "0";
1922
+ return "/".concat(this.rec().toString());
1923
+ }
1924
+ if (this.isInfi()) return "Infinity";
1925
+ // P^a (10{arrow,expans,megota})^repeation base
1926
+ var res = "";
1927
+ if (!this.layer) res += "";else if (this.layer < 3) res += "P".repeat(this.layer);else res += "P^" + this.layer + " ";
1928
+ for (var i = this.array.length - 1; i >= 0; i--) {
1929
+ var oper = this.array[i];
1930
+ var calc = "10{".concat(oper.arrow === Infinity ? "!" : oper.arrow).concat(oper.expans > 1 || oper.megota > 1 ? ",".concat(oper.expans === Infinity ? "!" : oper.expans) : "").concat(oper.megota > 1 ? ",".concat(oper.megota) : "", "}");
1931
+ if (oper.arrow == 1 && oper.expans == 1 && oper.megota == 1 && oper.repeat < 5) {
1932
+ calc = "e".repeat(oper.repeat);
1933
+ } else if (oper.arrow == 0 && oper.expans == 1 && oper.megota == 1) {
1934
+ calc = oper.repeat.toString();
1935
+ } else if (oper.repeat > 1) {
1936
+ calc = "(".concat(calc, ")^").concat(oper.repeat, " ");
1937
+ } else {
1938
+ calc = "".concat(calc);
1939
+ }
1940
+ res += "".concat(calc);
1941
+ }
1942
+ return res;
1943
+ }
1944
+ }, {
1945
+ key: "toJSON",
1946
+ value:
1947
+ /**
1948
+ * Convert `this` to a JSON object
1949
+ * @returns a JSON object
1950
+ */
1951
+ function toJSON() {
1952
+ return "PN" + this.toString();
1953
+ }
1954
+ }, {
1955
+ key: "arr01",
1956
+ get:
1957
+ /**
1958
+ * A property array value for version 0.1.x PowiainaNum.
1959
+ */
1960
+ function get() {
1961
+ var res = [0];
1962
+ for (var i = 0; i < this.array.length; i++) {
1963
+ if (i == 0) res[0] = this.array[i].repeat;else {
1964
+ // @ts-ignore
1965
+ res[i] = [0, 0, 0, 0];
1966
+ // @ts-ignore
1967
+ res[i][0] = this.array[i].arrow == Infinity ? "x" : this.array[i].arrow;
1968
+ // @ts-ignore
1969
+ res[i][1] = this.array[i].repeat;
1970
+ // @ts-ignore
1971
+ res[i][2] = this.array[i].expans == Infinity ? "x" : this.array[i].expans;
1972
+ // @ts-ignore
1973
+ res[i][3] = this.array[i].megota;
1974
+ }
1975
+ }
1976
+ return res;
1977
+ }
2114
1978
  }], [{
2115
1979
  key: "add",
2116
1980
  value: function add(t, other) {
2117
1981
  return new PowiainaNum(t).add(other);
2118
1982
  }
2119
- }, {
2120
- key: "plus",
2121
- value: function plus(t, other) {
2122
- return new PowiainaNum(t).add(other);
2123
- }
2124
1983
  }, {
2125
1984
  key: "sub",
2126
1985
  value: function sub(t, other) {
2127
1986
  return new PowiainaNum(t).sub(other);
2128
1987
  }
2129
- }, {
2130
- key: "minus",
2131
- value: function minus(t, other) {
2132
- return new PowiainaNum(t).sub(other);
2133
- }
2134
1988
  }, {
2135
1989
  key: "mul",
2136
1990
  value: function mul(t, other) {
2137
1991
  return new PowiainaNum(t).mul(other);
2138
1992
  }
2139
- }, {
2140
- key: "times",
2141
- value: function times(t, other) {
2142
- return new PowiainaNum(t).mul(other);
2143
- }
2144
1993
  }, {
2145
1994
  key: "div",
2146
1995
  value: function div(t, other) {
2147
1996
  return new PowiainaNum(t).div(other);
2148
1997
  }
2149
- }, {
2150
- key: "divide",
2151
- value: function divide(t, other) {
2152
- return new PowiainaNum(t).div(other);
2153
- }
2154
- }, {
2155
- key: "mod",
2156
- value: function mod(x, y) {
2157
- return new PowiainaNum(x).mod(y);
2158
- }
2159
- }, {
2160
- key: "modulus",
2161
- value: function modulus(x, y) {
2162
- return new PowiainaNum(x).mod(y);
2163
- }
2164
1998
  }, {
2165
1999
  key: "pow",
2166
2000
  value: function pow(t, other) {
@@ -2192,17 +2026,6 @@
2192
2026
  var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.E;
2193
2027
  return new PowiainaNum(t).log(base);
2194
2028
  }
2195
- }, {
2196
- key: "log2",
2197
- value: function log2(t) {
2198
- return new PowiainaNum(t).log2();
2199
- }
2200
- }, {
2201
- key: "logBase",
2202
- value: function logBase(t) {
2203
- var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.E;
2204
- return new PowiainaNum(t).log(base);
2205
- }
2206
2029
  }, {
2207
2030
  key: "pLog10",
2208
2031
  value: function pLog10(t) {
@@ -2354,27 +2177,6 @@
2354
2177
  };
2355
2178
  }
2356
2179
  }
2357
- }, {
2358
- key: "pentate",
2359
- value: function pentate(x, other, payload) {
2360
- return new PowiainaNum(x).arrow(3)(other, payload);
2361
- }
2362
- }, {
2363
- key: "hexate",
2364
- value: function hexate(x, other, payload) {
2365
- return new PowiainaNum(x).arrow(4)(other, payload);
2366
- }
2367
- }, {
2368
- key: "pent",
2369
- value: function pent(x, other, payload) {
2370
- return new PowiainaNum(x).arrow(3)(other, payload);
2371
- }
2372
- }, {
2373
- key: "penta_log",
2374
- value: function penta_log(x) {
2375
- var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
2376
- return new PowiainaNum(x).anyarrow_log(3)(base);
2377
- }
2378
2180
  }, {
2379
2181
  key: "expansion",
2380
2182
  value: function expansion(t, other) {
@@ -2397,7 +2199,7 @@
2397
2199
  args[_key8] = arguments[_key8];
2398
2200
  }
2399
2201
  function getArgs(x) {
2400
- if (args[x]) return new PowiainaNum(args[x]);
2202
+ if (args[x] !== undefined && args[x] !== null) return new PowiainaNum(args[x]);
2401
2203
  return new PowiainaNum(1);
2402
2204
  }
2403
2205
  if (getArgs(0).eq(1)) return new PowiainaNum(1);
@@ -2473,6 +2275,9 @@
2473
2275
  if (a == 0 && e == 1 && m > 1) {
2474
2276
  return [1, 1 / 0, m - 1];
2475
2277
  }
2278
+ if (e == 0 && m > 1) {
2279
+ return [1, 1 / 0, m - 1];
2280
+ }
2476
2281
  return [a, e, m];
2477
2282
  }
2478
2283
  if (megota.gt(MSI)) {
@@ -2486,7 +2291,8 @@
2486
2291
  return x.toString();
2487
2292
  }
2488
2293
  function getMSIForm(arrow, expans, megota) {
2489
- return "10{".concat(infToBang(arrow), ",").concat(infToBang(expans), ",").concat(megota, "}").concat(MSI);
2294
+ var conv = convertOperator(arrow, expans, megota);
2295
+ return "10{".concat(infToBang(conv[0]), ",").concat(infToBang(conv[1]), ",").concat(conv[2], "}").concat(MSI);
2490
2296
  }
2491
2297
  var t = base.clone();
2492
2298
  var arrows = new PowiainaNum(readArg(0));
@@ -2494,6 +2300,14 @@
2494
2300
  var _r, _r2;
2495
2301
  var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2496
2302
  console.log("".concat("-".repeat(depth), " {").concat(base2, ",").concat(power2, ",").concat(arrow2, ",").concat(expans2, ",").concat(megota2, "}"));
2303
+ if (depth >= 200) {
2304
+ return new PowiainaNum({
2305
+ layer: 0,
2306
+ array: [newOperator(10), newOperator(1, new PowiainaNum(arrow2).clampMax(MSI).toNumber(), new PowiainaNum(expans2).clampMax(MSI).toNumber(), new PowiainaNum(megota2).clampMax(MSI).toNumber())],
2307
+ sign: 1,
2308
+ small: false
2309
+ }).normalize();
2310
+ }
2497
2311
  var other = new PowiainaNum(other2);
2498
2312
  var r;
2499
2313
  if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
@@ -2509,6 +2323,10 @@
2509
2323
  return PowiainaNum.BEAF(t, t, power, expans.sub(1), megota, powiaina2, depth + 1);
2510
2324
  // {this, this, power, expans-1, megota}
2511
2325
  }
2326
+ if (expans.eq(0)) {
2327
+ return PowiainaNum.BEAF(t, t, t, power, megota.sub(1), powiaina2, depth + 1);
2328
+ // {this, this, power, expans-1, megota}
2329
+ }
2512
2330
  if (megota.eq(0)) {
2513
2331
  return PowiainaNum.BEAF(t, t, t, t, expans, new PowiainaNum(powiaina2).sub(1), depth + 1);
2514
2332
  }
@@ -2626,84 +2444,6 @@
2626
2444
  value: function clampMax() {
2627
2445
  return PowiainaNum.min.apply(PowiainaNum, arguments);
2628
2446
  }
2629
- }, {
2630
- key: "eq",
2631
- value: function eq(a, o) {
2632
- return new PowiainaNum(a).eq(o);
2633
- }
2634
- }, {
2635
- key: "equals",
2636
- value: function equals(a, o) {
2637
- return new PowiainaNum(a).eq(o);
2638
- }
2639
- }, {
2640
- key: "neq",
2641
- value: function neq(a, o) {
2642
- return new PowiainaNum(a).neq(o);
2643
- }
2644
- }, {
2645
- key: "notEquals",
2646
- value: function notEquals(a, o) {
2647
- return new PowiainaNum(a).notEquals(o);
2648
- }
2649
- }, {
2650
- key: "lt",
2651
- value: function lt(a, o) {
2652
- return new PowiainaNum(a).lt(o);
2653
- }
2654
- }, {
2655
- key: "gt",
2656
- value: function gt(a, o) {
2657
- return new PowiainaNum(a).gt(o);
2658
- }
2659
- }, {
2660
- key: "lte",
2661
- value: function lte(a, o) {
2662
- return new PowiainaNum(a).lte(o);
2663
- }
2664
- }, {
2665
- key: "gte",
2666
- value: function gte(a, o) {
2667
- return new PowiainaNum(a).gte(o);
2668
- }
2669
- }, {
2670
- key: "rec",
2671
- value: function rec(t) {
2672
- return new PowiainaNum(t).rec();
2673
- }
2674
- }, {
2675
- key: "recip",
2676
- value: function recip(t) {
2677
- return new PowiainaNum(t).rec();
2678
- }
2679
- }, {
2680
- key: "reciprocate",
2681
- value: function reciprocate(t) {
2682
- return new PowiainaNum(t).rec();
2683
- }
2684
- }, {
2685
- key: "floor",
2686
- value: function floor(x) {
2687
- return new PowiainaNum(x).floor();
2688
- }
2689
- }, {
2690
- key: "ceil",
2691
- value: function ceil(x) {
2692
- return new PowiainaNum(x).ceil();
2693
- }
2694
- }, {
2695
- key: "round",
2696
- value: function round(x) {
2697
- return new PowiainaNum(x).round();
2698
- }
2699
- }, {
2700
- key: "trunc",
2701
- value: function trunc(x) {
2702
- return new PowiainaNum(x).trunc();
2703
- }
2704
- /**
2705
- * @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
2706
- */
2707
2447
  }, {
2708
2448
  key: "sign",
2709
2449
  value: function sign(a) {
@@ -2718,17 +2458,6 @@
2718
2458
  key: "fromNumber",
2719
2459
  value: function fromNumber(x) {
2720
2460
  var obj = new PowiainaNum(); // NaN
2721
- obj.resetFromObject({
2722
- array: [{
2723
- arrow: 0,
2724
- expans: 1,
2725
- megota: 1,
2726
- repeat: NaN
2727
- }],
2728
- small: false,
2729
- layer: 0,
2730
- sign: 0
2731
- });
2732
2461
  if (x < 0) obj.sign = -1; // negative
2733
2462
  else if (x == 0) {
2734
2463
  obj.sign = 0;
@@ -2756,26 +2485,10 @@
2756
2485
  }, {
2757
2486
  key: "fromString",
2758
2487
  value: function fromString(input) {
2759
- if (PowiainaNum.usingBreakEternityLikeFromString && BE_REGEX.test(input)) {
2760
- /*
2761
- * 0i00000000a7 says that eee-3000 will wrongly parse to 1. So i added this
2762
- */
2763
- var a = input.match(/(e+-)(\d+(.\d+)?)/);
2764
- if (a) {
2765
- var e_s = a[1].length;
2766
- input = "e-" + "e".repeat(e_s - 1) + a[2];
2767
- }
2768
- }
2769
- return this.fromString_core(input);
2770
- }
2771
- }, {
2772
- key: "fromString_core",
2773
- value: function fromString_core(input) {
2774
2488
  var _b, _c, _d, _e, _f, _g;
2775
- var x = new PowiainaNum(NaN);
2489
+ var x = new PowiainaNum();
2776
2490
  // Judge the string was a number
2777
2491
  if (input.startsWith("PN")) input = input.substring(2);
2778
- if (input == "NaN") return PowiainaNum.NaN.clone();
2779
2492
  input = input.replace(/J\^(\d+)/g, "(10{!})^$1");
2780
2493
  input = input.replace(/J/g, "10{!}");
2781
2494
  input = input.replace(/K\^(\d+)/g, "(10{1,2})^$1");
@@ -2786,20 +2499,17 @@
2786
2499
  input = input.replace(/M/g, "10{!,2}");
2787
2500
  input = input.replace(/N\^(\d+)/g, "(10{1,!})^$1");
2788
2501
  input = input.replace(/N/g, "10{1,!}");
2789
- if (/^.*e-.*(e|\^).*/.test(input)) {
2790
- input = "/10^" + input.substring(input.indexOf("e-"));
2791
- }
2792
2502
  if (!isNaN(Number(input))) {
2793
2503
  var res = Number(input);
2794
- var a = false;
2504
+ var _a3 = false;
2795
2505
  if (res == 0) {
2796
2506
  if (/^((0)|(0*\.0+e\d+)|(0*\.0*))$/.test(input)) {
2797
- a = true;
2507
+ _a3 = true;
2798
2508
  }
2799
2509
  } else {
2800
- a = true;
2510
+ _a3 = true;
2801
2511
  }
2802
- if (!a) {
2512
+ if (!_a3) {
2803
2513
  var m = input.search(/e/);
2804
2514
  var exponent = input.substring((m == -1 ? input.length : m) + 1);
2805
2515
  var mantissa = input.substring(0, m == -1 ? undefined : m);
@@ -2809,11 +2519,11 @@
2809
2519
  // Is regular number gte 1:
2810
2520
  if (Number(mantissa) >= 1) {
2811
2521
  // check The mantissa is very long?
2812
- var log10mant = mantissa.length >= LONG_STRING_MIN_LENGTH ? log10LongString(mantissa) : Math.log10(Number(mantissa)); // sample 10
2813
- var log10int = Math.floor(log10mant); // sample 1
2814
- var log10float = log10mant - log10int; // sample 0;
2522
+ var log10mant = mantissa.length >= LONG_STRING_MIN_LENGTH ? log10LongString(mantissa) : Math.log10(Number(mantissa));
2523
+ var log10int = Math.floor(log10mant);
2524
+ var log10float = log10mant - log10int;
2815
2525
  mantissaME[0] = Math.pow(10, log10float);
2816
- mantissaME[1] += log10int;
2526
+ mantissaME[1] += log10float;
2817
2527
  } else {
2818
2528
  // If not , count how many zeros until reached non-zero numbers
2819
2529
  var zeros = countLeadingZerosAfterDecimal(mantissa);
@@ -2828,7 +2538,7 @@
2828
2538
  // /((a*10^b)^-1) = /(a^-1*10^-b) = /(a^-1 * 10 * 10^(-b-1))
2829
2539
  return PowiainaNum.pow(10, -mantissaME[1] - 1).mul(Math.pow(mantissaME[0], -1) * 10).rec();
2830
2540
  }
2831
- if (isFinite(res) && a) {
2541
+ if (isFinite(res) && _a3) {
2832
2542
  x = PowiainaNum.fromNumber(Number(input));
2833
2543
  return x;
2834
2544
  }
@@ -2845,7 +2555,6 @@
2845
2555
  return x;
2846
2556
  }
2847
2557
  input = replaceETo10(input);
2848
- input = removeCommasOutsideBraces(input);
2849
2558
  if (!isPowiainaNum.test(input)) {
2850
2559
  throw powiainaNumError + "malformed input: " + input;
2851
2560
  }
@@ -2858,31 +2567,28 @@
2858
2567
  input = input.substring(numSigns);
2859
2568
  }
2860
2569
  if (input[0] == "/") {
2861
- var _numSigns = input.search(/[^\/]/);
2862
- var _signs = input.substring(0, _numSigns);
2863
- recipIt = ((_e = (_d = _signs.match(/\//g)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) % 2 == 1;
2864
- input = input.substring(_numSigns);
2570
+ var numSigns = input.search(/[^\/]/);
2571
+ var signs = input.substring(0, numSigns);
2572
+ recipIt = ((_e = (_d = signs.match(/\//g)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) % 2 == 1;
2573
+ input = input.substring(numSigns);
2865
2574
  }
2866
2575
  if (input == "NaN") x.array = [newOperator(NaN)];else if (input == "Infinity") x.array = [newOperator(Infinity)];else {
2867
2576
  x.sign = 1;
2868
2577
  x.array = [newOperator(0)];
2869
- var _a3, b, c, d;
2578
+ var a, b, c, d;
2870
2579
  if (input[0] == "P") {
2871
2580
  if (input[1] == "^") {
2872
- _a3 = input.substring(2).search(/[^0-9]/) + 2;
2873
- x.layer = Number(input.substring(2, _a3));
2874
- input = input.substring(_a3 + 1);
2581
+ a = input.substring(2).search(/[^0-9]/) + 2;
2582
+ x.layer = Number(input.substring(2, a));
2583
+ input = input.substring(a + 1);
2875
2584
  } else {
2876
- _a3 = input.search(/[^P]/);
2877
- x.layer = _a3;
2878
- input = input.substring(_a3);
2585
+ a = input.search(/[^P]/);
2586
+ x.layer = a;
2587
+ input = input.substring(a);
2879
2588
  }
2880
2589
  }
2881
2590
  while (input) {
2882
2591
  if (/^(\(?10[\^\{])/.test(input)) {
2883
- var arrows = void 0,
2884
- expans = void 0,
2885
- megota = void 0;
2886
2592
  /*
2887
2593
  10^ - 匹配
2888
2594
  10{ - 匹配
@@ -2893,29 +2599,30 @@
2893
2599
  */
2894
2600
  if (input[0] == "(") input = input.substring(1);
2895
2601
  //cutted, 10^.... or 10{....
2602
+ var arrows, expans, megota;
2896
2603
  if (input[2] == "^") {
2897
- _a3 = input.substring(2).search(/[^\^]/);
2604
+ a = input.substring(2).search(/[^\^]/);
2898
2605
  //cut input to ^^...^^, and search how numbers
2899
- arrows = _a3;
2606
+ arrows = a;
2900
2607
  // 10^^^
2901
- b = _a3 + 2; // b points to after ^'s.
2608
+ b = a + 2; // b points to after ^'s.
2902
2609
  } else {
2903
2610
  // 10{...}
2904
- _a3 = input.indexOf("}");
2611
+ a = input.indexOf("}");
2905
2612
  // select contents between {...}
2906
- var tmp = input.substring(3, _a3).split(",");
2613
+ var tmp = input.substring(3, a).split(",");
2907
2614
  arrows = Number(tmp[0] == "!" ? Infinity : tmp[0]);
2908
2615
  expans = Number((_f = tmp[1] == "!" ? Infinity : tmp[1]) !== null && _f !== void 0 ? _f : 1);
2909
2616
  megota = Number((_g = tmp[2]) !== null && _g !== void 0 ? _g : 1);
2910
- b = _a3 + 1;
2617
+ b = a + 1;
2911
2618
  // b points to after }.
2912
2619
  }
2913
2620
  input = input.substring(b);
2914
2621
  if (input[0] == ")") {
2915
2622
  // )^....<Space>
2916
- _a3 = input.indexOf(" ");
2917
- c = Number(input.substring(2, _a3)); // Select contents between )^....<Space>
2918
- input = input.substring(_a3 + 1); // c points to after <Space>
2623
+ a = input.indexOf(" ");
2624
+ c = Number(input.substring(2, a)); // Select contents between )^....<Space>
2625
+ input = input.substring(a + 1); // c points to after <Space>
2919
2626
  } else {
2920
2627
  c = 1; // There is only spaces, count as <ONE>
2921
2628
  }
@@ -2926,21 +2633,21 @@
2926
2633
  x.array.splice(1, 0, newOperator(c, 1, expans, megota));
2927
2634
  }
2928
2635
  } else if (arrows == 2 && expans == 1 && megota == 1) {
2929
- _a3 = x.array.length >= 2 && x.array[1].arrow == 1 ? x.array[1].repeat : 0;
2636
+ a = x.array.length >= 2 && x.array[1].arrow == 1 ? x.array[1].repeat : 0;
2930
2637
  b = x.array[0].repeat;
2931
- if (b >= 1e10) ++_a3;
2932
- if (b >= 10) ++_a3;
2933
- x.array[0].repeat = _a3;
2638
+ if (b >= 1e10) ++a;
2639
+ if (b >= 10) ++a;
2640
+ x.array[0].repeat = a;
2934
2641
  if (x.array.length >= 2 && x.array[1].arrow == 1) x.array.splice(1, 1);
2935
2642
  d = x.getOperatorIndex(2);
2936
2643
  if (Number.isInteger(d)) x.array[d].repeat += c;else x.array.splice(Math.ceil(d), 0, newOperator(c, 2, expans, megota));
2937
2644
  } else if (isFinite(arrows)) {
2938
- _a3 = x.getOperator(arrows - 1);
2645
+ a = x.getOperator(arrows - 1);
2939
2646
  b = x.getOperator(arrows - 2);
2940
- if (b >= 10) ++_a3;
2647
+ if (b >= 10) ++a;
2941
2648
  d = x.getOperatorIndex(arrows);
2942
2649
  x.array.splice(1, Math.ceil(d) - 1);
2943
- x.array[0].repeat = _a3;
2650
+ x.array[0].repeat = a;
2944
2651
  if (Number.isInteger(d)) x.array[1].repeat += c;else x.array.splice(1, 0, newOperator(c, arrows, expans, megota));
2945
2652
  } else {
2946
2653
  x.array.splice(1, 0, newOperator(c, arrows, expans, megota));
@@ -2949,10 +2656,10 @@
2949
2656
  break;
2950
2657
  }
2951
2658
  }
2952
- _a3 = input.split(/[Ee]/);
2659
+ a = input.split(/[Ee]/);
2953
2660
  b = [x.array[0].repeat, 0];
2954
2661
  c = 1;
2955
- for (var i = _a3.length - 1; i >= 0; --i) {
2662
+ for (var _i2 = a.length - 1; _i2 >= 0; --_i2) {
2956
2663
  //The things that are already there
2957
2664
  if (b[0] < MSI_LOG10 && b[1] === 0) {
2958
2665
  b[0] = Math.pow(10, c * b[0]);
@@ -2969,12 +2676,12 @@
2969
2676
  b[1]++;
2970
2677
  }
2971
2678
  //Multiplying coefficient
2972
- var decimalPointPos = _a3[i].indexOf(".");
2973
- var intPartLen = decimalPointPos == -1 ? _a3[i].length : decimalPointPos;
2679
+ var decimalPointPos = a[_i2].indexOf(".");
2680
+ var intPartLen = decimalPointPos == -1 ? a[_i2].length : decimalPointPos;
2974
2681
  if (b[1] === 0) {
2975
- if (intPartLen >= LONG_STRING_MIN_LENGTH) b[0] = Math.log10(b[0]) + log10LongString(_a3[i].substring(0, intPartLen)), b[1] = 1;else if (_a3[i]) b[0] *= Number(_a3[i]);
2682
+ if (intPartLen >= LONG_STRING_MIN_LENGTH) b[0] = Math.log10(b[0]) + log10LongString(a[_i2].substring(0, intPartLen)), b[1] = 1;else if (a[_i2]) b[0] *= Number(a[_i2]);
2976
2683
  } else {
2977
- d = intPartLen >= LONG_STRING_MIN_LENGTH ? log10LongString(_a3[i].substring(0, intPartLen)) : _a3[i] ? Math.log10(Number(_a3[i])) : 0;
2684
+ d = intPartLen >= LONG_STRING_MIN_LENGTH ? log10LongString(a[_i2].substring(0, intPartLen)) : a[_i2] ? Math.log10(Number(a[_i2])) : 0;
2978
2685
  if (b[1] == 1) {
2979
2686
  b[0] += d;
2980
2687
  } else if (b[1] == 2 && b[0] < MSI_LOG10 + Math.log10(d)) {
@@ -3005,17 +2712,6 @@
3005
2712
  key: "fromObject",
3006
2713
  value: function fromObject(powlikeObject) {
3007
2714
  var obj = new PowiainaNum();
3008
- obj.resetFromObject({
3009
- array: [{
3010
- arrow: 0,
3011
- expans: 1,
3012
- megota: 1,
3013
- repeat: NaN
3014
- }],
3015
- small: false,
3016
- layer: 0,
3017
- sign: 0
3018
- });
3019
2715
  obj.array = [];
3020
2716
  if (isExpantaNumArray(powlikeObject)) {
3021
2717
  for (var i = 0; i < powlikeObject.length; i++) {
@@ -3033,8 +2729,8 @@
3033
2729
  } else if (isPowiainaNum01XArray(powlikeObject)) {
3034
2730
  var arrayobj = powlikeObject;
3035
2731
  obj.array[0] = newOperator(arrayobj[0]);
3036
- for (var _i4 = 1; _i4 < arrayobj.length; _i4++) {
3037
- var b = arrayobj[_i4];
2732
+ for (var _i3 = 1; _i3 < arrayobj.length; _i3++) {
2733
+ var b = arrayobj[_i3];
3038
2734
  obj.array[1] = newOperator(b[1], replaceXToInfinity(b[0]), replaceXToInfinity(b[2]), b[3]);
3039
2735
  }
3040
2736
  obj.small = false;
@@ -3042,21 +2738,21 @@
3042
2738
  obj.layer = 0;
3043
2739
  return obj;
3044
2740
  } else {
3045
- obj.resetFromObject(powlikeObject);
2741
+ for (var _i4 = 0; _i4 < powlikeObject.array.length; _i4++) {
2742
+ obj.array[_i4] = {
2743
+ arrow: powlikeObject.array[_i4].arrow,
2744
+ expans: powlikeObject.array[_i4].expans,
2745
+ megota: powlikeObject.array[_i4].megota,
2746
+ repeat: powlikeObject.array[_i4].repeat,
2747
+ valuereplaced: powlikeObject.array[_i4].valuereplaced
2748
+ };
2749
+ }
2750
+ obj.small = powlikeObject.small;
2751
+ obj.sign = powlikeObject.sign;
2752
+ obj.layer = powlikeObject.layer;
3046
2753
  return obj;
3047
2754
  }
3048
2755
  }
3049
- }, {
3050
- key: "grahalFunction",
3051
- value: function grahalFunction(layers2) {
3052
- var layers = new PowiainaNum(layers2);
3053
- if (!layers.isInt() || layers.lt(0) || layers.isNaN()) return PowiainaNum.NaN.clone();
3054
- if (layers.eq(1)) return new PowiainaNum("10^^^(10^)^7625597484984 3638334640023.7783");else if (layers.lte(MSI)) {
3055
- return new PowiainaNum("(10{!})^".concat(layers.toNumber(), " 10^^^(10^)^7625597484984 3638334640023.7783"));
3056
- } else {
3057
- return PowiainaNum.BEAF(3, layers, 1, 2);
3058
- }
3059
- }
3060
2756
  }]);
3061
2757
  }();
3062
2758
  _a = Symbol.toStringTag;
@@ -3273,15 +2969,6 @@
3273
2969
  PowiainaNum.POW_2_44_MOD_PI = 1.701173079953;
3274
2970
  //#endregion
3275
2971
  PowiainaNum.arrowFuncMap = new Map();
3276
- //#region configurations
3277
- /**
3278
- * 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.
3279
- */
3280
- PowiainaNum.usingBreakEternityLikeFromString = false;
3281
- /**
3282
- * If you set this config to true, the `constructor` method will return Zero instead of NaN when call new PowiainaNum() with no arguments.
3283
- */
3284
- PowiainaNum.blankArgumentConstructorReturnZero = false;
3285
2972
 
3286
2973
  exports.arraySortFunction = arraySortFunction;
3287
2974
  exports["default"] = PowiainaNum;