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.
- package/dist/PowiainaNum.cjs.js +270 -583
- package/dist/PowiainaNum.esm.js +270 -583
- package/dist/PowiainaNum.js +270 -583
- package/dist/PowiainaNum.min.js +1 -1
- package/dist/index.d.ts +18 -70
- package/package.json +1 -1
package/dist/PowiainaNum.esm.js
CHANGED
|
@@ -62,8 +62,6 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
62
62
|
|
|
63
63
|
/* Author: VeryrrDefine 0.2.0-beta.1.1*/
|
|
64
64
|
var _a;
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region constants
|
|
67
65
|
var powiainaNumError = "[PowiainaNum 0.2 error]";
|
|
68
66
|
var MSI = 9007199254740991;
|
|
69
67
|
var MSI_LOG10 = 15.954589770191003;
|
|
@@ -71,8 +69,6 @@ var MSI_REC = 1.1102230246251568e-16;
|
|
|
71
69
|
var LONG_STRING_MIN_LENGTH = 17;
|
|
72
70
|
var EXP_E_REC = 1.444667861009766;
|
|
73
71
|
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+))$/;
|
|
74
|
-
var BE_REGEX = /^((\d+(\.\d*)?|\d*\.\d+)?([EeFf]([-\+]?)))*(0|\d+(\.\d*)?|\d*\.\d+)$/;
|
|
75
|
-
//#endregion
|
|
76
72
|
//#region some useful functions
|
|
77
73
|
function newOperator(r) {
|
|
78
74
|
var a = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
@@ -86,29 +82,6 @@ function newOperator(r) {
|
|
|
86
82
|
valuereplaced: a == Infinity ? 0 : e == Infinity ? 1 : -1
|
|
87
83
|
};
|
|
88
84
|
}
|
|
89
|
-
function removeCommasOutsideBraces(input) {
|
|
90
|
-
var result = "";
|
|
91
|
-
var inBraces = false;
|
|
92
|
-
for (var i = 0; i < input.length; i++) {
|
|
93
|
-
var _char = input[i];
|
|
94
|
-
if (_char === "{") {
|
|
95
|
-
inBraces = true;
|
|
96
|
-
result += _char;
|
|
97
|
-
} else if (_char === "}") {
|
|
98
|
-
inBraces = false;
|
|
99
|
-
result += _char;
|
|
100
|
-
} else if (_char === ",") {
|
|
101
|
-
// 只有在花括号内部才保留逗号
|
|
102
|
-
if (inBraces) {
|
|
103
|
-
result += _char;
|
|
104
|
-
}
|
|
105
|
-
// 如果在花括号外部,就不添加到结果中(相当于删除)
|
|
106
|
-
} else {
|
|
107
|
-
result += _char;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return result;
|
|
111
|
-
}
|
|
112
85
|
// parse 0.1.x PowiainaNum.js string
|
|
113
86
|
function parseLegacyPowiainaNumString(str) {
|
|
114
87
|
var pattern = /l(\d+)\s+s(\d+)\s+a(\[.*\])/;
|
|
@@ -141,7 +114,7 @@ function compareTuples() {
|
|
|
141
114
|
function replaceETo10(str) {
|
|
142
115
|
// 使用正则表达式匹配 (e^数字) 的模式
|
|
143
116
|
// 正则解释:\(e\^(\d+)\) 匹配 (e^数字),其中 \d+ 匹配一个或多个数字
|
|
144
|
-
return str.replace(/\(e\^(\d+)\)/g, "(10^)^$1 ").replace(/(\d+)
|
|
117
|
+
return str.replace(/\(e\^(\d+)\)/g, "(10^)^$1 ").replace(/(\d+)\x20*PT/g, "(10^)^$1 ");
|
|
145
118
|
}
|
|
146
119
|
/**
|
|
147
120
|
* 把一个字符串很长的数进行以10为底的对数
|
|
@@ -195,10 +168,8 @@ var OMEGA = 0.56714329040978387299997; // W(1, 0)
|
|
|
195
168
|
// The evaluation can become inaccurate very close to the branch point
|
|
196
169
|
// Evaluates W(x, 0) if principal is true, W(x, -1) if principal is false
|
|
197
170
|
function f_lambertw(z) {
|
|
198
|
-
var
|
|
199
|
-
var
|
|
200
|
-
var tol = t;
|
|
201
|
-
var principal = pr;
|
|
171
|
+
var tol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e-10;
|
|
172
|
+
var principal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
202
173
|
var w;
|
|
203
174
|
var wn;
|
|
204
175
|
if (!Number.isFinite(z)) {
|
|
@@ -361,26 +332,16 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
361
332
|
this.small = false;
|
|
362
333
|
this.sign = 0;
|
|
363
334
|
this.layer = 0;
|
|
364
|
-
if (
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
} else if (typeof arg1 == "string") {
|
|
375
|
-
var _obj2 = PowiainaNum.fromString(arg1);
|
|
376
|
-
this.resetFromObject(_obj2);
|
|
377
|
-
} else {
|
|
378
|
-
var isn = arg1;
|
|
379
|
-
}
|
|
380
|
-
} catch (e) {
|
|
381
|
-
console.error("Malformed input");
|
|
382
|
-
console.error(e);
|
|
383
|
-
}
|
|
335
|
+
if (typeof arg1 == "undefined") ; else if (typeof arg1 == "number") {
|
|
336
|
+
var obj = PowiainaNum.fromNumber(arg1);
|
|
337
|
+
this.resetFromObject(obj);
|
|
338
|
+
} else if (_typeof(arg1) == "object") {
|
|
339
|
+
var _obj = PowiainaNum.fromObject(arg1);
|
|
340
|
+
this.resetFromObject(_obj);
|
|
341
|
+
} else if (typeof arg1 == "string") {
|
|
342
|
+
var _obj2 = PowiainaNum.fromString(arg1);
|
|
343
|
+
this.resetFromObject(_obj2);
|
|
344
|
+
} else ;
|
|
384
345
|
}
|
|
385
346
|
//#region 4 Basic calculates.
|
|
386
347
|
/**
|
|
@@ -391,7 +352,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
391
352
|
key: "add",
|
|
392
353
|
value: function add(other) {
|
|
393
354
|
var _b, _c, _d, _e;
|
|
394
|
-
var x = this.clone()
|
|
355
|
+
var x = this.clone();
|
|
395
356
|
var y = new PowiainaNum(other);
|
|
396
357
|
// inf + -inf = nan
|
|
397
358
|
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();
|
|
@@ -452,7 +413,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
452
413
|
mult *= -1;
|
|
453
414
|
}
|
|
454
415
|
if (t == 0) throw Error("Encounter a calculate error");
|
|
455
|
-
r = PowiainaNum
|
|
416
|
+
r = new PowiainaNum();
|
|
456
417
|
r.sign = 1;
|
|
457
418
|
if (l > MSI_LOG10 || l < -MSI_LOG10) {
|
|
458
419
|
r.array = [newOperator(l, 0), newOperator(1, 1)];
|
|
@@ -463,21 +424,11 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
463
424
|
r.sign *= mult;
|
|
464
425
|
return r;
|
|
465
426
|
}
|
|
466
|
-
}, {
|
|
467
|
-
key: "plus",
|
|
468
|
-
value: function plus(other) {
|
|
469
|
-
return this.add(other);
|
|
470
|
-
}
|
|
471
427
|
}, {
|
|
472
428
|
key: "sub",
|
|
473
429
|
value: function sub(a) {
|
|
474
430
|
return this.add(new PowiainaNum(a).neg());
|
|
475
431
|
}
|
|
476
|
-
}, {
|
|
477
|
-
key: "minus",
|
|
478
|
-
value: function minus(other) {
|
|
479
|
-
return this.sub(other);
|
|
480
|
-
}
|
|
481
432
|
}, {
|
|
482
433
|
key: "mul",
|
|
483
434
|
value: function mul(other) {
|
|
@@ -511,22 +462,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
511
462
|
r.sign = x.sign * y.sign;
|
|
512
463
|
return r;
|
|
513
464
|
}
|
|
514
|
-
}, {
|
|
515
|
-
key: "times",
|
|
516
|
-
value: function times(other) {
|
|
517
|
-
return this.mul(other);
|
|
518
|
-
}
|
|
519
465
|
}, {
|
|
520
466
|
key: "div",
|
|
521
467
|
value: function div(other) {
|
|
522
468
|
var x = new PowiainaNum(other).rec();
|
|
523
469
|
return this.mul(x);
|
|
524
470
|
}
|
|
525
|
-
}, {
|
|
526
|
-
key: "divide",
|
|
527
|
-
value: function divide(other) {
|
|
528
|
-
return this.div(other);
|
|
529
|
-
}
|
|
530
471
|
}, {
|
|
531
472
|
key: "mod",
|
|
532
473
|
value: function mod(x) {
|
|
@@ -534,20 +475,14 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
534
475
|
var division = this.div(other);
|
|
535
476
|
return division.sub(division.floor()).mul(other);
|
|
536
477
|
}
|
|
537
|
-
}, {
|
|
538
|
-
key: "modulus",
|
|
539
|
-
value: function modulus(x) {
|
|
540
|
-
return this.mod(x);
|
|
541
|
-
}
|
|
542
|
-
}, {
|
|
543
|
-
key: "pow10",
|
|
544
|
-
value:
|
|
545
478
|
//#endregion
|
|
546
479
|
//#region power
|
|
547
480
|
/**
|
|
548
481
|
* @returns 10 to the power of `this`
|
|
549
482
|
*/
|
|
550
|
-
|
|
483
|
+
}, {
|
|
484
|
+
key: "pow10",
|
|
485
|
+
value: function pow10() {
|
|
551
486
|
var _b, _c;
|
|
552
487
|
var r = this.clone();
|
|
553
488
|
// inf & nan check
|
|
@@ -577,16 +512,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
577
512
|
if (!other.isFinite()) return other.clone();
|
|
578
513
|
if (!this.isFinite()) return this.clone();
|
|
579
514
|
if (this.eq(10)) return other.pow10();
|
|
580
|
-
if (other.isneg()) return this.pow(other.neg()).rec();
|
|
581
515
|
if (this.isneg()) {
|
|
582
|
-
if (!other.isInt())
|
|
583
|
-
if (other.small) {
|
|
584
|
-
if (other.rec().div(2).eq(1)) {
|
|
585
|
-
return this.neg().pow(other).neg();
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
return PowiainaNum.NaN.clone();
|
|
589
|
-
}
|
|
516
|
+
if (!other.isInt()) return PowiainaNum.NaN.clone();
|
|
590
517
|
var r = this.abs().pow(other);
|
|
591
518
|
r.sign = function () {
|
|
592
519
|
var a = other.mod(2).round();
|
|
@@ -663,16 +590,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
663
590
|
var other = new PowiainaNum(base);
|
|
664
591
|
return this.log10().div(other.log10());
|
|
665
592
|
}
|
|
666
|
-
}, {
|
|
667
|
-
key: "log2",
|
|
668
|
-
value: function log2() {
|
|
669
|
-
return this.log(2);
|
|
670
|
-
}
|
|
671
|
-
}, {
|
|
672
|
-
key: "logBase",
|
|
673
|
-
value: function logBase(a) {
|
|
674
|
-
return this.log(a);
|
|
675
|
-
}
|
|
676
593
|
}, {
|
|
677
594
|
key: "ln",
|
|
678
595
|
value: function ln() {
|
|
@@ -780,8 +697,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
780
697
|
//Code from break_eternity.js
|
|
781
698
|
//Some special values, for testing: https://en.wikipedia.org/wiki/Lambert_W_function#Special_values
|
|
782
699
|
function lambertw() {
|
|
783
|
-
var
|
|
784
|
-
var principal = princ;
|
|
700
|
+
var principal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
785
701
|
if (this.lt(-0.3678794411710499)) {
|
|
786
702
|
return PowiainaNum.NaN.clone(); //complex
|
|
787
703
|
} else if (principal) {
|
|
@@ -799,9 +715,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
799
715
|
if (this.sign === 1) {
|
|
800
716
|
return PowiainaNum.NaN.clone(); //complex
|
|
801
717
|
}
|
|
802
|
-
if (this.
|
|
718
|
+
if (this.layer === 0) {
|
|
803
719
|
return PowiainaNum.fromNumber(f_lambertw(this.sign * this.array[0].repeat, 1e-10, false));
|
|
804
|
-
} else if (this.
|
|
720
|
+
} else if (this.layer == 1) {
|
|
805
721
|
return d_lambertw(this, 1e-10, false);
|
|
806
722
|
} else {
|
|
807
723
|
return this.neg().rec().lambertw().neg();
|
|
@@ -822,9 +738,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
822
738
|
var payl = new PowiainaNum(payload);
|
|
823
739
|
if (t.isNaN() || other.isNaN() || payl.isNaN()) return PowiainaNum.NaN.clone();
|
|
824
740
|
if (t.eq(1)) return PowiainaNum.ONE.clone();
|
|
825
|
-
if (payl.neq(PowiainaNum.ONE)
|
|
826
|
-
other = other.add(payl.slog(t));
|
|
827
|
-
}
|
|
741
|
+
if (payl.neq(PowiainaNum.ONE)) other = other.add(payl.slog(t));
|
|
828
742
|
var negln;
|
|
829
743
|
if (other.isInfi() && other.sign > 0) {
|
|
830
744
|
if (t.gte(EXP_E_REC)) return PowiainaNum.POSITIVE_INFINITY.clone();
|
|
@@ -1154,9 +1068,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1154
1068
|
// base^base^... = x? (? bases)
|
|
1155
1069
|
var r = 0;
|
|
1156
1070
|
// 计算x与base的差距
|
|
1157
|
-
var
|
|
1158
|
-
if (
|
|
1159
|
-
var l =
|
|
1071
|
+
var t = x.getOperator(arrowsNum) - b.getOperator(arrowsNum);
|
|
1072
|
+
if (t > 3) {
|
|
1073
|
+
var l = t - 3;
|
|
1160
1074
|
r += l;
|
|
1161
1075
|
x.setOperator(x.getOperator(arrowsNum) - l, arrowsNum);
|
|
1162
1076
|
}
|
|
@@ -1198,18 +1112,18 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1198
1112
|
}
|
|
1199
1113
|
}, {
|
|
1200
1114
|
key: "pentate",
|
|
1201
|
-
value: function pentate(other
|
|
1202
|
-
return this.arrow(3)(other
|
|
1115
|
+
value: function pentate(other) {
|
|
1116
|
+
return this.arrow(3)(other);
|
|
1203
1117
|
}
|
|
1204
1118
|
}, {
|
|
1205
1119
|
key: "hexate",
|
|
1206
|
-
value: function hexate(other
|
|
1207
|
-
return this.arrow(4)(other
|
|
1120
|
+
value: function hexate(other) {
|
|
1121
|
+
return this.arrow(4)(other);
|
|
1208
1122
|
}
|
|
1209
1123
|
}, {
|
|
1210
1124
|
key: "pent",
|
|
1211
|
-
value: function pent(other
|
|
1212
|
-
return this.arrow(3)(other
|
|
1125
|
+
value: function pent(other) {
|
|
1126
|
+
return this.arrow(3)(other);
|
|
1213
1127
|
}
|
|
1214
1128
|
}, {
|
|
1215
1129
|
key: "penta_log",
|
|
@@ -1217,9 +1131,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1217
1131
|
var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1218
1132
|
return this.anyarrow_log(3)(base);
|
|
1219
1133
|
}
|
|
1220
|
-
}, {
|
|
1221
|
-
key: "expansion",
|
|
1222
|
-
value:
|
|
1223
1134
|
/**
|
|
1224
1135
|
* Expansion, which is `this`{{1}}`other2`.
|
|
1225
1136
|
*
|
|
@@ -1227,7 +1138,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1227
1138
|
*
|
|
1228
1139
|
* @url https://googology.fandom.com/wiki/Expansion
|
|
1229
1140
|
*/
|
|
1230
|
-
|
|
1141
|
+
}, {
|
|
1142
|
+
key: "expansion",
|
|
1143
|
+
value: function expansion(other2) {
|
|
1231
1144
|
var other = new PowiainaNum(other2);
|
|
1232
1145
|
var t = this.clone();
|
|
1233
1146
|
if (other.lt(PowiainaNum.ZERO) || !other.isInt()) return PowiainaNum.NaN.clone();
|
|
@@ -1540,16 +1453,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1540
1453
|
var t = this.cmp(other);
|
|
1541
1454
|
return t == 0 || t == 1;
|
|
1542
1455
|
}
|
|
1543
|
-
}, {
|
|
1544
|
-
key: "equals",
|
|
1545
|
-
value: function equals(other) {
|
|
1546
|
-
return this.eq(other);
|
|
1547
|
-
}
|
|
1548
|
-
}, {
|
|
1549
|
-
key: "notEquals",
|
|
1550
|
-
value: function notEquals(other) {
|
|
1551
|
-
return this.neq(other);
|
|
1552
|
-
}
|
|
1553
1456
|
}, {
|
|
1554
1457
|
key: "eq_tolerance",
|
|
1555
1458
|
value: function eq_tolerance(value) {
|
|
@@ -1611,16 +1514,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1611
1514
|
a.small = !a.small;
|
|
1612
1515
|
return a;
|
|
1613
1516
|
}
|
|
1614
|
-
}, {
|
|
1615
|
-
key: "recip",
|
|
1616
|
-
value: function recip() {
|
|
1617
|
-
return this.rec();
|
|
1618
|
-
}
|
|
1619
|
-
}, {
|
|
1620
|
-
key: "reciprocate",
|
|
1621
|
-
value: function reciprocate() {
|
|
1622
|
-
return this.rec();
|
|
1623
|
-
}
|
|
1624
1517
|
}, {
|
|
1625
1518
|
key: "floor",
|
|
1626
1519
|
value: function floor() {
|
|
@@ -1661,9 +1554,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1661
1554
|
r.sign = this.sign;
|
|
1662
1555
|
return r;
|
|
1663
1556
|
}
|
|
1664
|
-
}, {
|
|
1665
|
-
key: "trunc",
|
|
1666
|
-
value:
|
|
1667
1557
|
/**
|
|
1668
1558
|
* Work like `Math.trunc`,
|
|
1669
1559
|
*
|
|
@@ -1676,10 +1566,15 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1676
1566
|
* new PowiainaNum(-1.114514).trunc() == new PowiainaNum(-1)
|
|
1677
1567
|
* @returns
|
|
1678
1568
|
*/
|
|
1679
|
-
|
|
1569
|
+
}, {
|
|
1570
|
+
key: "trunc",
|
|
1571
|
+
value: function trunc() {
|
|
1680
1572
|
var y = this.clone();
|
|
1681
1573
|
return y.gte(0) ? y.floor() : y.ceil();
|
|
1682
1574
|
}
|
|
1575
|
+
/**
|
|
1576
|
+
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
1577
|
+
*/
|
|
1683
1578
|
}, {
|
|
1684
1579
|
key: "isNaN",
|
|
1685
1580
|
value: function (_isNaN) {
|
|
@@ -1742,164 +1637,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1742
1637
|
value: function isneg() {
|
|
1743
1638
|
return this.sign < 0;
|
|
1744
1639
|
}
|
|
1745
|
-
}, {
|
|
1746
|
-
key: "getOperatorIndex",
|
|
1747
|
-
value:
|
|
1748
|
-
//#endregion
|
|
1749
|
-
//#region operators
|
|
1750
|
-
/**
|
|
1751
|
-
* @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.
|
|
1752
|
-
*/
|
|
1753
|
-
function getOperatorIndex(arrow) {
|
|
1754
|
-
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1755
|
-
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1756
|
-
for (var i = 0; i < this.array.length; i++) {
|
|
1757
|
-
var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
|
|
1758
|
-
if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
|
|
1759
|
-
if (cmp == 1) return i - 0.5; // It's between [xx, xx,xx*,?,*xx]!
|
|
1760
|
-
}
|
|
1761
|
-
return this.array.length - 0.5;
|
|
1762
|
-
}
|
|
1763
|
-
/**
|
|
1764
|
-
* @returns number repeats of operators with given arguments.
|
|
1765
|
-
*/
|
|
1766
|
-
}, {
|
|
1767
|
-
key: "getOperator",
|
|
1768
|
-
value: function getOperator(arrow) {
|
|
1769
|
-
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1770
|
-
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1771
|
-
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1772
|
-
if (!this.array[index]) return 0;
|
|
1773
|
-
return this.array[index].repeat;
|
|
1774
|
-
}
|
|
1775
|
-
/**
|
|
1776
|
-
* Modify the repeat of operator
|
|
1777
|
-
* @param number val the repeat of operator will modify to array.
|
|
1778
|
-
* @returns bool Is the operators array changed?
|
|
1779
|
-
*/
|
|
1780
|
-
}, {
|
|
1781
|
-
key: "setOperator",
|
|
1782
|
-
value: function setOperator(val, arrow) {
|
|
1783
|
-
var expans = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1784
|
-
var megota = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
1785
|
-
// if (arrow!=0&&val==0) return false;
|
|
1786
|
-
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1787
|
-
if (!this.array[index]) {
|
|
1788
|
-
this.array.splice(Math.ceil(index), 0, {
|
|
1789
|
-
arrow: arrow,
|
|
1790
|
-
expans: expans,
|
|
1791
|
-
megota: megota,
|
|
1792
|
-
valuereplaced: expans === Infinity ? 1 : arrow == Infinity ? 0 : -1,
|
|
1793
|
-
repeat: val
|
|
1794
|
-
});
|
|
1795
|
-
return true;
|
|
1796
|
-
}
|
|
1797
|
-
this.array[index].repeat = val;
|
|
1798
|
-
// this.normalize()
|
|
1799
|
-
return false;
|
|
1800
|
-
}
|
|
1801
|
-
//#endregion
|
|
1802
|
-
//#region converters
|
|
1803
|
-
/**
|
|
1804
|
-
* Convert `this` to Javascript `number`
|
|
1805
|
-
*
|
|
1806
|
-
* returns `Infinity` when the number is greater than `Number.MAX_VALUE`
|
|
1807
|
-
*/
|
|
1808
|
-
}, {
|
|
1809
|
-
key: "toNumber",
|
|
1810
|
-
value: function toNumber() {
|
|
1811
|
-
if (this.sign == -1) return -this.neg().toNumber();
|
|
1812
|
-
if (this.small) return 1 / this.rec().toNumber();
|
|
1813
|
-
if (this.array.length > 2) return Infinity;
|
|
1814
|
-
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));
|
|
1815
|
-
return NaN;
|
|
1816
|
-
}
|
|
1817
|
-
/**
|
|
1818
|
-
* Convert `this` to a string
|
|
1819
|
-
*/
|
|
1820
|
-
}, {
|
|
1821
|
-
key: "toString_core",
|
|
1822
|
-
value: function toString_core() {
|
|
1823
|
-
if (this.isNaN()) return "NaN";
|
|
1824
|
-
if (this.sign == -1) return "-".concat(this.neg().toString());
|
|
1825
|
-
if (this.small) {
|
|
1826
|
-
if (this.isZero()) return "0";
|
|
1827
|
-
return "/".concat(this.rec().toString());
|
|
1828
|
-
}
|
|
1829
|
-
if (this.isInfi()) return "Infinity";
|
|
1830
|
-
// P^a (10{arrow,expans,megota})^repeation base
|
|
1831
|
-
var res = "";
|
|
1832
|
-
if (!this.layer) res += "";else if (this.layer < 3) res += "P".repeat(this.layer);else res += "P^" + this.layer + " ";
|
|
1833
|
-
for (var i = this.array.length - 1; i >= 0; i--) {
|
|
1834
|
-
var oper = this.array[i];
|
|
1835
|
-
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) : "", "}");
|
|
1836
|
-
if (oper.arrow == 1 && oper.expans == 1 && oper.megota == 1 && oper.repeat < 5) {
|
|
1837
|
-
calc = "e".repeat(oper.repeat);
|
|
1838
|
-
} else if (oper.arrow == 0 && oper.expans == 1 && oper.megota == 1) {
|
|
1839
|
-
calc = oper.repeat.toString();
|
|
1840
|
-
} else if (oper.repeat > 1) {
|
|
1841
|
-
calc = "(".concat(calc, ")^").concat(oper.repeat, " ");
|
|
1842
|
-
} else {
|
|
1843
|
-
calc = "".concat(calc);
|
|
1844
|
-
}
|
|
1845
|
-
res += "".concat(calc);
|
|
1846
|
-
}
|
|
1847
|
-
return res;
|
|
1848
|
-
}
|
|
1849
|
-
}, {
|
|
1850
|
-
key: "toString",
|
|
1851
|
-
value: function toString() {
|
|
1852
|
-
try {
|
|
1853
|
-
return this.toString_core();
|
|
1854
|
-
} catch (_b) {
|
|
1855
|
-
console.error("Checked error when converting to string");
|
|
1856
|
-
return "NaN";
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
}, {
|
|
1860
|
-
key: "toJSON",
|
|
1861
|
-
value:
|
|
1862
|
-
/**
|
|
1863
|
-
* Convert `this` to a JSON object
|
|
1864
|
-
* @returns a JSON object
|
|
1865
|
-
*/
|
|
1866
|
-
function toJSON() {
|
|
1867
|
-
return "PN" + this.toString();
|
|
1868
|
-
}
|
|
1869
|
-
}, {
|
|
1870
|
-
key: "arr01",
|
|
1871
|
-
get:
|
|
1872
|
-
/**
|
|
1873
|
-
* A property array value for version 0.1.x PowiainaNum.
|
|
1874
|
-
*/
|
|
1875
|
-
function get() {
|
|
1876
|
-
var res = [0];
|
|
1877
|
-
for (var i = 0; i < this.array.length; i++) {
|
|
1878
|
-
if (i == 0) res[0] = this.array[i].repeat;else {
|
|
1879
|
-
// @ts-ignore
|
|
1880
|
-
res[i] = [0, 0, 0, 0];
|
|
1881
|
-
// @ts-ignore
|
|
1882
|
-
res[i][0] = this.array[i].arrow == Infinity ? "x" : this.array[i].arrow;
|
|
1883
|
-
// @ts-ignore
|
|
1884
|
-
res[i][1] = this.array[i].repeat;
|
|
1885
|
-
// @ts-ignore
|
|
1886
|
-
res[i][2] = this.array[i].expans == Infinity ? "x" : this.array[i].expans;
|
|
1887
|
-
// @ts-ignore
|
|
1888
|
-
res[i][3] = this.array[i].megota;
|
|
1889
|
-
}
|
|
1890
|
-
}
|
|
1891
|
-
return res;
|
|
1892
|
-
}
|
|
1893
|
-
//#endregion
|
|
1894
|
-
//#region useless functions
|
|
1895
|
-
/**
|
|
1896
|
-
* This function is for NaNe308, if you want to calculate G(x), use this function directly.
|
|
1897
|
-
*/
|
|
1898
1640
|
}, {
|
|
1899
1641
|
key: "normalize",
|
|
1900
1642
|
value:
|
|
1901
1643
|
//#endregion
|
|
1902
|
-
//#region other functions
|
|
1903
1644
|
/**
|
|
1904
1645
|
* Normalize functions will make this number convert into standard format.(it also change `this`, like [].sort)
|
|
1905
1646
|
* @returns normalized number
|
|
@@ -1908,14 +1649,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1908
1649
|
//TODO: normalize
|
|
1909
1650
|
var renormalize = true;
|
|
1910
1651
|
var x = this;
|
|
1911
|
-
|
|
1912
|
-
x.array = [newOperator(NaN, 0, 1, 1)];
|
|
1913
|
-
}
|
|
1914
|
-
if (this.sign === undefined) this.sign = 0;
|
|
1915
|
-
if (this.layer === undefined) this.layer = 0;
|
|
1916
|
-
for (var i = 0; i < this.array.length; i++) {
|
|
1652
|
+
for (var _i = 0; _i < this.array.length; _i++) {
|
|
1917
1653
|
// Check what is infinity
|
|
1918
|
-
if (this.array[
|
|
1654
|
+
if (this.array[_i].repeat == Infinity) {
|
|
1919
1655
|
this.array = [{
|
|
1920
1656
|
arrow: 0,
|
|
1921
1657
|
expans: 1,
|
|
@@ -1926,8 +1662,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1926
1662
|
return this;
|
|
1927
1663
|
}
|
|
1928
1664
|
}
|
|
1929
|
-
for (var
|
|
1930
|
-
var e = x.array[
|
|
1665
|
+
for (var i = 1; i < x.array.length; ++i) {
|
|
1666
|
+
var e = x.array[i];
|
|
1931
1667
|
if (e.arrow === null || e.arrow === undefined) {
|
|
1932
1668
|
e.arrow = 0;
|
|
1933
1669
|
}
|
|
@@ -1958,28 +1694,28 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1958
1694
|
renormalize = false;
|
|
1959
1695
|
// Sort arrays.
|
|
1960
1696
|
this.array.sort(arraySortFunction);
|
|
1961
|
-
for (
|
|
1962
|
-
if (x.array[
|
|
1697
|
+
for (i = 1; i < x.array.length - 1; ++i) {
|
|
1698
|
+
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) {
|
|
1963
1699
|
// same array's merge
|
|
1964
|
-
x.array[
|
|
1965
|
-
x.array.splice(
|
|
1966
|
-
--
|
|
1700
|
+
x.array[i].repeat += x.array[i + 1].repeat;
|
|
1701
|
+
x.array.splice(i + 1, 1);
|
|
1702
|
+
--i;
|
|
1967
1703
|
renormalize = true;
|
|
1968
1704
|
}
|
|
1969
1705
|
}
|
|
1970
|
-
for (
|
|
1706
|
+
for (i = 1; i < x.array.length; ++i) {
|
|
1971
1707
|
// If there is a 0 repeat operator, remove it.
|
|
1972
|
-
if (x.array[
|
|
1973
|
-
x.array.splice(
|
|
1974
|
-
--
|
|
1708
|
+
if (x.array[i].arrow !== 0 && (x.array[i].repeat === 0 || x.array[i].repeat === null || x.array[i].repeat === undefined)) {
|
|
1709
|
+
x.array.splice(i, 1);
|
|
1710
|
+
--i;
|
|
1975
1711
|
continue;
|
|
1976
1712
|
}
|
|
1977
1713
|
// If there is a operator which arrow 0 and brace count >=2
|
|
1978
1714
|
// replace it as arrow replacement operaotr
|
|
1979
|
-
if (x.array[
|
|
1980
|
-
x.array[
|
|
1981
|
-
x.array[
|
|
1982
|
-
x.array[
|
|
1715
|
+
if (x.array[i].arrow == 0 && x.array[i].expans >= 2) {
|
|
1716
|
+
x.array[i].arrow = Infinity;
|
|
1717
|
+
x.array[i].valuereplaced = 0;
|
|
1718
|
+
x.array[i].expans = x.array[i].expans - 1;
|
|
1983
1719
|
}
|
|
1984
1720
|
}
|
|
1985
1721
|
if (x.array.length > PowiainaNum.maxOps) x.array.splice(1, x.array.length - PowiainaNum.maxOps); // max operators check
|
|
@@ -2009,11 +1745,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2009
1745
|
this.small = !this.small;
|
|
2010
1746
|
renormalize = true;
|
|
2011
1747
|
}
|
|
2012
|
-
// for a = 1, small should false.
|
|
2013
|
-
if (this.array.length == 1 && this.array[0].repeat == 1 && this.small) {
|
|
2014
|
-
this.small = false;
|
|
2015
|
-
renormalize = true;
|
|
2016
|
-
}
|
|
2017
1748
|
// for any 10{X>9e15}10, replace into 10{!}X;
|
|
2018
1749
|
if (this.array.length >= 2 && this.array[1].arrow >= MSI) {
|
|
2019
1750
|
this.array[0].repeat = this.array[1].arrow;
|
|
@@ -2069,6 +1800,61 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2069
1800
|
} while (renormalize);
|
|
2070
1801
|
return this;
|
|
2071
1802
|
}
|
|
1803
|
+
//#region operators
|
|
1804
|
+
/**
|
|
1805
|
+
* @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.
|
|
1806
|
+
*/
|
|
1807
|
+
}, {
|
|
1808
|
+
key: "getOperatorIndex",
|
|
1809
|
+
value: function getOperatorIndex(arrow) {
|
|
1810
|
+
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1811
|
+
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1812
|
+
for (var i = 0; i < this.array.length; i++) {
|
|
1813
|
+
var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
|
|
1814
|
+
if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
|
|
1815
|
+
if (cmp == 1) return i - 0.5; // It's between [xx, xx,xx*,?,*xx]!
|
|
1816
|
+
}
|
|
1817
|
+
return this.array.length - 0.5;
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* @returns number repeats of operators with given arguments.
|
|
1821
|
+
*/
|
|
1822
|
+
}, {
|
|
1823
|
+
key: "getOperator",
|
|
1824
|
+
value: function getOperator(arrow) {
|
|
1825
|
+
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1826
|
+
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1827
|
+
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1828
|
+
if (!this.array[index]) return 0;
|
|
1829
|
+
return this.array[index].repeat;
|
|
1830
|
+
}
|
|
1831
|
+
/**
|
|
1832
|
+
* Modify the repeat of operator
|
|
1833
|
+
* @param number val the repeat of operator will modify to array.
|
|
1834
|
+
* @returns bool Is the operators array changed?
|
|
1835
|
+
*/
|
|
1836
|
+
}, {
|
|
1837
|
+
key: "setOperator",
|
|
1838
|
+
value: function setOperator(val, arrow) {
|
|
1839
|
+
var expans = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1840
|
+
var megota = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
1841
|
+
// if (arrow!=0&&val==0) return false;
|
|
1842
|
+
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1843
|
+
if (!this.array[index]) {
|
|
1844
|
+
this.array.splice(Math.ceil(index), 0, {
|
|
1845
|
+
arrow: arrow,
|
|
1846
|
+
expans: expans,
|
|
1847
|
+
megota: megota,
|
|
1848
|
+
valuereplaced: expans === Infinity ? 1 : arrow == Infinity ? 0 : -1,
|
|
1849
|
+
repeat: val
|
|
1850
|
+
});
|
|
1851
|
+
return true;
|
|
1852
|
+
}
|
|
1853
|
+
this.array[index].repeat = val;
|
|
1854
|
+
// this.normalize()
|
|
1855
|
+
return false;
|
|
1856
|
+
}
|
|
1857
|
+
//#endregion
|
|
2072
1858
|
/**
|
|
2073
1859
|
* @returns a PowiainaNum object which deep copied from `this` object.
|
|
2074
1860
|
*/
|
|
@@ -2087,9 +1873,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2087
1873
|
}, {
|
|
2088
1874
|
key: "resetFromObject",
|
|
2089
1875
|
value: function resetFromObject(powlikeObject) {
|
|
2090
|
-
if (!powlikeObject.array) {
|
|
2091
|
-
return;
|
|
2092
|
-
}
|
|
2093
1876
|
this.array = [];
|
|
2094
1877
|
for (var i = 0; i < powlikeObject.array.length; i++) {
|
|
2095
1878
|
this.array[i] = {
|
|
@@ -2105,56 +1888,107 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2105
1888
|
this.layer = powlikeObject.layer;
|
|
2106
1889
|
return this;
|
|
2107
1890
|
}
|
|
1891
|
+
//#region converters
|
|
1892
|
+
/**
|
|
1893
|
+
* Convert `this` to Javascript `number`
|
|
1894
|
+
*
|
|
1895
|
+
* returns `Infinity` when the number is greater than `Number.MAX_VALUE`
|
|
1896
|
+
*/
|
|
1897
|
+
}, {
|
|
1898
|
+
key: "toNumber",
|
|
1899
|
+
value: function toNumber() {
|
|
1900
|
+
if (this.sign == -1) return -this.neg().toNumber();
|
|
1901
|
+
if (this.small) return 1 / this.rec().toNumber();
|
|
1902
|
+
if (this.array.length > 2) return Infinity;
|
|
1903
|
+
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));
|
|
1904
|
+
return NaN;
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Convert `this` to a string
|
|
1908
|
+
*/
|
|
1909
|
+
}, {
|
|
1910
|
+
key: "toString",
|
|
1911
|
+
value: function toString() {
|
|
1912
|
+
if (this.isNaN()) return "NaN";
|
|
1913
|
+
if (this.sign == -1) return "-".concat(this.neg().toString());
|
|
1914
|
+
if (this.small) {
|
|
1915
|
+
if (this.isZero()) return "0";
|
|
1916
|
+
return "/".concat(this.rec().toString());
|
|
1917
|
+
}
|
|
1918
|
+
if (this.isInfi()) return "Infinity";
|
|
1919
|
+
// P^a (10{arrow,expans,megota})^repeation base
|
|
1920
|
+
var res = "";
|
|
1921
|
+
if (!this.layer) res += "";else if (this.layer < 3) res += "P".repeat(this.layer);else res += "P^" + this.layer + " ";
|
|
1922
|
+
for (var i = this.array.length - 1; i >= 0; i--) {
|
|
1923
|
+
var oper = this.array[i];
|
|
1924
|
+
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) : "", "}");
|
|
1925
|
+
if (oper.arrow == 1 && oper.expans == 1 && oper.megota == 1 && oper.repeat < 5) {
|
|
1926
|
+
calc = "e".repeat(oper.repeat);
|
|
1927
|
+
} else if (oper.arrow == 0 && oper.expans == 1 && oper.megota == 1) {
|
|
1928
|
+
calc = oper.repeat.toString();
|
|
1929
|
+
} else if (oper.repeat > 1) {
|
|
1930
|
+
calc = "(".concat(calc, ")^").concat(oper.repeat, " ");
|
|
1931
|
+
} else {
|
|
1932
|
+
calc = "".concat(calc);
|
|
1933
|
+
}
|
|
1934
|
+
res += "".concat(calc);
|
|
1935
|
+
}
|
|
1936
|
+
return res;
|
|
1937
|
+
}
|
|
1938
|
+
}, {
|
|
1939
|
+
key: "toJSON",
|
|
1940
|
+
value:
|
|
1941
|
+
/**
|
|
1942
|
+
* Convert `this` to a JSON object
|
|
1943
|
+
* @returns a JSON object
|
|
1944
|
+
*/
|
|
1945
|
+
function toJSON() {
|
|
1946
|
+
return "PN" + this.toString();
|
|
1947
|
+
}
|
|
1948
|
+
}, {
|
|
1949
|
+
key: "arr01",
|
|
1950
|
+
get:
|
|
1951
|
+
/**
|
|
1952
|
+
* A property array value for version 0.1.x PowiainaNum.
|
|
1953
|
+
*/
|
|
1954
|
+
function get() {
|
|
1955
|
+
var res = [0];
|
|
1956
|
+
for (var i = 0; i < this.array.length; i++) {
|
|
1957
|
+
if (i == 0) res[0] = this.array[i].repeat;else {
|
|
1958
|
+
// @ts-ignore
|
|
1959
|
+
res[i] = [0, 0, 0, 0];
|
|
1960
|
+
// @ts-ignore
|
|
1961
|
+
res[i][0] = this.array[i].arrow == Infinity ? "x" : this.array[i].arrow;
|
|
1962
|
+
// @ts-ignore
|
|
1963
|
+
res[i][1] = this.array[i].repeat;
|
|
1964
|
+
// @ts-ignore
|
|
1965
|
+
res[i][2] = this.array[i].expans == Infinity ? "x" : this.array[i].expans;
|
|
1966
|
+
// @ts-ignore
|
|
1967
|
+
res[i][3] = this.array[i].megota;
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
return res;
|
|
1971
|
+
}
|
|
2108
1972
|
}], [{
|
|
2109
1973
|
key: "add",
|
|
2110
1974
|
value: function add(t, other) {
|
|
2111
1975
|
return new PowiainaNum(t).add(other);
|
|
2112
1976
|
}
|
|
2113
|
-
}, {
|
|
2114
|
-
key: "plus",
|
|
2115
|
-
value: function plus(t, other) {
|
|
2116
|
-
return new PowiainaNum(t).add(other);
|
|
2117
|
-
}
|
|
2118
1977
|
}, {
|
|
2119
1978
|
key: "sub",
|
|
2120
1979
|
value: function sub(t, other) {
|
|
2121
1980
|
return new PowiainaNum(t).sub(other);
|
|
2122
1981
|
}
|
|
2123
|
-
}, {
|
|
2124
|
-
key: "minus",
|
|
2125
|
-
value: function minus(t, other) {
|
|
2126
|
-
return new PowiainaNum(t).sub(other);
|
|
2127
|
-
}
|
|
2128
1982
|
}, {
|
|
2129
1983
|
key: "mul",
|
|
2130
1984
|
value: function mul(t, other) {
|
|
2131
1985
|
return new PowiainaNum(t).mul(other);
|
|
2132
1986
|
}
|
|
2133
|
-
}, {
|
|
2134
|
-
key: "times",
|
|
2135
|
-
value: function times(t, other) {
|
|
2136
|
-
return new PowiainaNum(t).mul(other);
|
|
2137
|
-
}
|
|
2138
1987
|
}, {
|
|
2139
1988
|
key: "div",
|
|
2140
1989
|
value: function div(t, other) {
|
|
2141
1990
|
return new PowiainaNum(t).div(other);
|
|
2142
1991
|
}
|
|
2143
|
-
}, {
|
|
2144
|
-
key: "divide",
|
|
2145
|
-
value: function divide(t, other) {
|
|
2146
|
-
return new PowiainaNum(t).div(other);
|
|
2147
|
-
}
|
|
2148
|
-
}, {
|
|
2149
|
-
key: "mod",
|
|
2150
|
-
value: function mod(x, y) {
|
|
2151
|
-
return new PowiainaNum(x).mod(y);
|
|
2152
|
-
}
|
|
2153
|
-
}, {
|
|
2154
|
-
key: "modulus",
|
|
2155
|
-
value: function modulus(x, y) {
|
|
2156
|
-
return new PowiainaNum(x).mod(y);
|
|
2157
|
-
}
|
|
2158
1992
|
}, {
|
|
2159
1993
|
key: "pow",
|
|
2160
1994
|
value: function pow(t, other) {
|
|
@@ -2186,17 +2020,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2186
2020
|
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.E;
|
|
2187
2021
|
return new PowiainaNum(t).log(base);
|
|
2188
2022
|
}
|
|
2189
|
-
}, {
|
|
2190
|
-
key: "log2",
|
|
2191
|
-
value: function log2(t) {
|
|
2192
|
-
return new PowiainaNum(t).log2();
|
|
2193
|
-
}
|
|
2194
|
-
}, {
|
|
2195
|
-
key: "logBase",
|
|
2196
|
-
value: function logBase(t) {
|
|
2197
|
-
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.E;
|
|
2198
|
-
return new PowiainaNum(t).log(base);
|
|
2199
|
-
}
|
|
2200
2023
|
}, {
|
|
2201
2024
|
key: "pLog10",
|
|
2202
2025
|
value: function pLog10(t) {
|
|
@@ -2348,27 +2171,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2348
2171
|
};
|
|
2349
2172
|
}
|
|
2350
2173
|
}
|
|
2351
|
-
}, {
|
|
2352
|
-
key: "pentate",
|
|
2353
|
-
value: function pentate(x, other, payload) {
|
|
2354
|
-
return new PowiainaNum(x).arrow(3)(other, payload);
|
|
2355
|
-
}
|
|
2356
|
-
}, {
|
|
2357
|
-
key: "hexate",
|
|
2358
|
-
value: function hexate(x, other, payload) {
|
|
2359
|
-
return new PowiainaNum(x).arrow(4)(other, payload);
|
|
2360
|
-
}
|
|
2361
|
-
}, {
|
|
2362
|
-
key: "pent",
|
|
2363
|
-
value: function pent(x, other, payload) {
|
|
2364
|
-
return new PowiainaNum(x).arrow(3)(other, payload);
|
|
2365
|
-
}
|
|
2366
|
-
}, {
|
|
2367
|
-
key: "penta_log",
|
|
2368
|
-
value: function penta_log(x) {
|
|
2369
|
-
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
2370
|
-
return new PowiainaNum(x).anyarrow_log(3)(base);
|
|
2371
|
-
}
|
|
2372
2174
|
}, {
|
|
2373
2175
|
key: "expansion",
|
|
2374
2176
|
value: function expansion(t, other) {
|
|
@@ -2391,7 +2193,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2391
2193
|
args[_key8] = arguments[_key8];
|
|
2392
2194
|
}
|
|
2393
2195
|
function getArgs(x) {
|
|
2394
|
-
if (args[x]) return new PowiainaNum(args[x]);
|
|
2196
|
+
if (args[x] !== undefined && args[x] !== null) return new PowiainaNum(args[x]);
|
|
2395
2197
|
return new PowiainaNum(1);
|
|
2396
2198
|
}
|
|
2397
2199
|
if (getArgs(0).eq(1)) return new PowiainaNum(1);
|
|
@@ -2467,6 +2269,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2467
2269
|
if (a == 0 && e == 1 && m > 1) {
|
|
2468
2270
|
return [1, 1 / 0, m - 1];
|
|
2469
2271
|
}
|
|
2272
|
+
if (e == 0 && m > 1) {
|
|
2273
|
+
return [1, 1 / 0, m - 1];
|
|
2274
|
+
}
|
|
2470
2275
|
return [a, e, m];
|
|
2471
2276
|
}
|
|
2472
2277
|
if (megota.gt(MSI)) {
|
|
@@ -2480,7 +2285,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2480
2285
|
return x.toString();
|
|
2481
2286
|
}
|
|
2482
2287
|
function getMSIForm(arrow, expans, megota) {
|
|
2483
|
-
|
|
2288
|
+
var conv = convertOperator(arrow, expans, megota);
|
|
2289
|
+
return "10{".concat(infToBang(conv[0]), ",").concat(infToBang(conv[1]), ",").concat(conv[2], "}").concat(MSI);
|
|
2484
2290
|
}
|
|
2485
2291
|
var t = base.clone();
|
|
2486
2292
|
var arrows = new PowiainaNum(readArg(0));
|
|
@@ -2488,6 +2294,14 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2488
2294
|
var _r, _r2;
|
|
2489
2295
|
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
2490
2296
|
console.log("".concat("-".repeat(depth), " {").concat(base2, ",").concat(power2, ",").concat(arrow2, ",").concat(expans2, ",").concat(megota2, "}"));
|
|
2297
|
+
if (depth >= 200) {
|
|
2298
|
+
return new PowiainaNum({
|
|
2299
|
+
layer: 0,
|
|
2300
|
+
array: [newOperator(10), newOperator(1, new PowiainaNum(arrow2).clampMax(MSI).toNumber(), new PowiainaNum(expans2).clampMax(MSI).toNumber(), new PowiainaNum(megota2).clampMax(MSI).toNumber())],
|
|
2301
|
+
sign: 1,
|
|
2302
|
+
small: false
|
|
2303
|
+
}).normalize();
|
|
2304
|
+
}
|
|
2491
2305
|
var other = new PowiainaNum(other2);
|
|
2492
2306
|
var r;
|
|
2493
2307
|
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
|
|
@@ -2503,6 +2317,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2503
2317
|
return PowiainaNum.BEAF(t, t, power, expans.sub(1), megota, powiaina2, depth + 1);
|
|
2504
2318
|
// {this, this, power, expans-1, megota}
|
|
2505
2319
|
}
|
|
2320
|
+
if (expans.eq(0)) {
|
|
2321
|
+
return PowiainaNum.BEAF(t, t, t, power, megota.sub(1), powiaina2, depth + 1);
|
|
2322
|
+
// {this, this, power, expans-1, megota}
|
|
2323
|
+
}
|
|
2506
2324
|
if (megota.eq(0)) {
|
|
2507
2325
|
return PowiainaNum.BEAF(t, t, t, t, expans, new PowiainaNum(powiaina2).sub(1), depth + 1);
|
|
2508
2326
|
}
|
|
@@ -2620,84 +2438,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2620
2438
|
value: function clampMax() {
|
|
2621
2439
|
return PowiainaNum.min.apply(PowiainaNum, arguments);
|
|
2622
2440
|
}
|
|
2623
|
-
}, {
|
|
2624
|
-
key: "eq",
|
|
2625
|
-
value: function eq(a, o) {
|
|
2626
|
-
return new PowiainaNum(a).eq(o);
|
|
2627
|
-
}
|
|
2628
|
-
}, {
|
|
2629
|
-
key: "equals",
|
|
2630
|
-
value: function equals(a, o) {
|
|
2631
|
-
return new PowiainaNum(a).eq(o);
|
|
2632
|
-
}
|
|
2633
|
-
}, {
|
|
2634
|
-
key: "neq",
|
|
2635
|
-
value: function neq(a, o) {
|
|
2636
|
-
return new PowiainaNum(a).neq(o);
|
|
2637
|
-
}
|
|
2638
|
-
}, {
|
|
2639
|
-
key: "notEquals",
|
|
2640
|
-
value: function notEquals(a, o) {
|
|
2641
|
-
return new PowiainaNum(a).notEquals(o);
|
|
2642
|
-
}
|
|
2643
|
-
}, {
|
|
2644
|
-
key: "lt",
|
|
2645
|
-
value: function lt(a, o) {
|
|
2646
|
-
return new PowiainaNum(a).lt(o);
|
|
2647
|
-
}
|
|
2648
|
-
}, {
|
|
2649
|
-
key: "gt",
|
|
2650
|
-
value: function gt(a, o) {
|
|
2651
|
-
return new PowiainaNum(a).gt(o);
|
|
2652
|
-
}
|
|
2653
|
-
}, {
|
|
2654
|
-
key: "lte",
|
|
2655
|
-
value: function lte(a, o) {
|
|
2656
|
-
return new PowiainaNum(a).lte(o);
|
|
2657
|
-
}
|
|
2658
|
-
}, {
|
|
2659
|
-
key: "gte",
|
|
2660
|
-
value: function gte(a, o) {
|
|
2661
|
-
return new PowiainaNum(a).gte(o);
|
|
2662
|
-
}
|
|
2663
|
-
}, {
|
|
2664
|
-
key: "rec",
|
|
2665
|
-
value: function rec(t) {
|
|
2666
|
-
return new PowiainaNum(t).rec();
|
|
2667
|
-
}
|
|
2668
|
-
}, {
|
|
2669
|
-
key: "recip",
|
|
2670
|
-
value: function recip(t) {
|
|
2671
|
-
return new PowiainaNum(t).rec();
|
|
2672
|
-
}
|
|
2673
|
-
}, {
|
|
2674
|
-
key: "reciprocate",
|
|
2675
|
-
value: function reciprocate(t) {
|
|
2676
|
-
return new PowiainaNum(t).rec();
|
|
2677
|
-
}
|
|
2678
|
-
}, {
|
|
2679
|
-
key: "floor",
|
|
2680
|
-
value: function floor(x) {
|
|
2681
|
-
return new PowiainaNum(x).floor();
|
|
2682
|
-
}
|
|
2683
|
-
}, {
|
|
2684
|
-
key: "ceil",
|
|
2685
|
-
value: function ceil(x) {
|
|
2686
|
-
return new PowiainaNum(x).ceil();
|
|
2687
|
-
}
|
|
2688
|
-
}, {
|
|
2689
|
-
key: "round",
|
|
2690
|
-
value: function round(x) {
|
|
2691
|
-
return new PowiainaNum(x).round();
|
|
2692
|
-
}
|
|
2693
|
-
}, {
|
|
2694
|
-
key: "trunc",
|
|
2695
|
-
value: function trunc(x) {
|
|
2696
|
-
return new PowiainaNum(x).trunc();
|
|
2697
|
-
}
|
|
2698
|
-
/**
|
|
2699
|
-
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
2700
|
-
*/
|
|
2701
2441
|
}, {
|
|
2702
2442
|
key: "sign",
|
|
2703
2443
|
value: function sign(a) {
|
|
@@ -2712,17 +2452,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2712
2452
|
key: "fromNumber",
|
|
2713
2453
|
value: function fromNumber(x) {
|
|
2714
2454
|
var obj = new PowiainaNum(); // NaN
|
|
2715
|
-
obj.resetFromObject({
|
|
2716
|
-
array: [{
|
|
2717
|
-
arrow: 0,
|
|
2718
|
-
expans: 1,
|
|
2719
|
-
megota: 1,
|
|
2720
|
-
repeat: NaN
|
|
2721
|
-
}],
|
|
2722
|
-
small: false,
|
|
2723
|
-
layer: 0,
|
|
2724
|
-
sign: 0
|
|
2725
|
-
});
|
|
2726
2455
|
if (x < 0) obj.sign = -1; // negative
|
|
2727
2456
|
else if (x == 0) {
|
|
2728
2457
|
obj.sign = 0;
|
|
@@ -2750,26 +2479,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2750
2479
|
}, {
|
|
2751
2480
|
key: "fromString",
|
|
2752
2481
|
value: function fromString(input) {
|
|
2753
|
-
if (PowiainaNum.usingBreakEternityLikeFromString && BE_REGEX.test(input)) {
|
|
2754
|
-
/*
|
|
2755
|
-
* 0i00000000a7 says that eee-3000 will wrongly parse to 1. So i added this
|
|
2756
|
-
*/
|
|
2757
|
-
var a = input.match(/(e+-)(\d+(.\d+)?)/);
|
|
2758
|
-
if (a) {
|
|
2759
|
-
var e_s = a[1].length;
|
|
2760
|
-
input = "e-" + "e".repeat(e_s - 1) + a[2];
|
|
2761
|
-
}
|
|
2762
|
-
}
|
|
2763
|
-
return this.fromString_core(input);
|
|
2764
|
-
}
|
|
2765
|
-
}, {
|
|
2766
|
-
key: "fromString_core",
|
|
2767
|
-
value: function fromString_core(input) {
|
|
2768
2482
|
var _b, _c, _d, _e, _f, _g;
|
|
2769
|
-
var x = new PowiainaNum(
|
|
2483
|
+
var x = new PowiainaNum();
|
|
2770
2484
|
// Judge the string was a number
|
|
2771
2485
|
if (input.startsWith("PN")) input = input.substring(2);
|
|
2772
|
-
if (input == "NaN") return PowiainaNum.NaN.clone();
|
|
2773
2486
|
input = input.replace(/J\^(\d+)/g, "(10{!})^$1");
|
|
2774
2487
|
input = input.replace(/J/g, "10{!}");
|
|
2775
2488
|
input = input.replace(/K\^(\d+)/g, "(10{1,2})^$1");
|
|
@@ -2780,20 +2493,17 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2780
2493
|
input = input.replace(/M/g, "10{!,2}");
|
|
2781
2494
|
input = input.replace(/N\^(\d+)/g, "(10{1,!})^$1");
|
|
2782
2495
|
input = input.replace(/N/g, "10{1,!}");
|
|
2783
|
-
if (/^.*e-.*(e|\^).*/.test(input)) {
|
|
2784
|
-
input = "/10^" + input.substring(input.indexOf("e-"));
|
|
2785
|
-
}
|
|
2786
2496
|
if (!isNaN(Number(input))) {
|
|
2787
2497
|
var res = Number(input);
|
|
2788
|
-
var
|
|
2498
|
+
var _a3 = false;
|
|
2789
2499
|
if (res == 0) {
|
|
2790
2500
|
if (/^((0)|(0*\.0+e\d+)|(0*\.0*))$/.test(input)) {
|
|
2791
|
-
|
|
2501
|
+
_a3 = true;
|
|
2792
2502
|
}
|
|
2793
2503
|
} else {
|
|
2794
|
-
|
|
2504
|
+
_a3 = true;
|
|
2795
2505
|
}
|
|
2796
|
-
if (!
|
|
2506
|
+
if (!_a3) {
|
|
2797
2507
|
var m = input.search(/e/);
|
|
2798
2508
|
var exponent = input.substring((m == -1 ? input.length : m) + 1);
|
|
2799
2509
|
var mantissa = input.substring(0, m == -1 ? undefined : m);
|
|
@@ -2803,11 +2513,11 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2803
2513
|
// Is regular number gte 1:
|
|
2804
2514
|
if (Number(mantissa) >= 1) {
|
|
2805
2515
|
// check The mantissa is very long?
|
|
2806
|
-
var log10mant = mantissa.length >= LONG_STRING_MIN_LENGTH ? log10LongString(mantissa) : Math.log10(Number(mantissa));
|
|
2807
|
-
var log10int = Math.floor(log10mant);
|
|
2808
|
-
var log10float = log10mant - log10int;
|
|
2516
|
+
var log10mant = mantissa.length >= LONG_STRING_MIN_LENGTH ? log10LongString(mantissa) : Math.log10(Number(mantissa));
|
|
2517
|
+
var log10int = Math.floor(log10mant);
|
|
2518
|
+
var log10float = log10mant - log10int;
|
|
2809
2519
|
mantissaME[0] = Math.pow(10, log10float);
|
|
2810
|
-
mantissaME[1] +=
|
|
2520
|
+
mantissaME[1] += log10float;
|
|
2811
2521
|
} else {
|
|
2812
2522
|
// If not , count how many zeros until reached non-zero numbers
|
|
2813
2523
|
var zeros = countLeadingZerosAfterDecimal(mantissa);
|
|
@@ -2822,7 +2532,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2822
2532
|
// /((a*10^b)^-1) = /(a^-1*10^-b) = /(a^-1 * 10 * 10^(-b-1))
|
|
2823
2533
|
return PowiainaNum.pow(10, -mantissaME[1] - 1).mul(Math.pow(mantissaME[0], -1) * 10).rec();
|
|
2824
2534
|
}
|
|
2825
|
-
if (isFinite(res) &&
|
|
2535
|
+
if (isFinite(res) && _a3) {
|
|
2826
2536
|
x = PowiainaNum.fromNumber(Number(input));
|
|
2827
2537
|
return x;
|
|
2828
2538
|
}
|
|
@@ -2839,7 +2549,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2839
2549
|
return x;
|
|
2840
2550
|
}
|
|
2841
2551
|
input = replaceETo10(input);
|
|
2842
|
-
input = removeCommasOutsideBraces(input);
|
|
2843
2552
|
if (!isPowiainaNum.test(input)) {
|
|
2844
2553
|
throw powiainaNumError + "malformed input: " + input;
|
|
2845
2554
|
}
|
|
@@ -2852,31 +2561,28 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2852
2561
|
input = input.substring(numSigns);
|
|
2853
2562
|
}
|
|
2854
2563
|
if (input[0] == "/") {
|
|
2855
|
-
var
|
|
2856
|
-
var
|
|
2857
|
-
recipIt = ((_e = (_d =
|
|
2858
|
-
input = input.substring(
|
|
2564
|
+
var numSigns = input.search(/[^\/]/);
|
|
2565
|
+
var signs = input.substring(0, numSigns);
|
|
2566
|
+
recipIt = ((_e = (_d = signs.match(/\//g)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) % 2 == 1;
|
|
2567
|
+
input = input.substring(numSigns);
|
|
2859
2568
|
}
|
|
2860
2569
|
if (input == "NaN") x.array = [newOperator(NaN)];else if (input == "Infinity") x.array = [newOperator(Infinity)];else {
|
|
2861
2570
|
x.sign = 1;
|
|
2862
2571
|
x.array = [newOperator(0)];
|
|
2863
|
-
var
|
|
2572
|
+
var a, b, c, d;
|
|
2864
2573
|
if (input[0] == "P") {
|
|
2865
2574
|
if (input[1] == "^") {
|
|
2866
|
-
|
|
2867
|
-
x.layer = Number(input.substring(2,
|
|
2868
|
-
input = input.substring(
|
|
2575
|
+
a = input.substring(2).search(/[^0-9]/) + 2;
|
|
2576
|
+
x.layer = Number(input.substring(2, a));
|
|
2577
|
+
input = input.substring(a + 1);
|
|
2869
2578
|
} else {
|
|
2870
|
-
|
|
2871
|
-
x.layer =
|
|
2872
|
-
input = input.substring(
|
|
2579
|
+
a = input.search(/[^P]/);
|
|
2580
|
+
x.layer = a;
|
|
2581
|
+
input = input.substring(a);
|
|
2873
2582
|
}
|
|
2874
2583
|
}
|
|
2875
2584
|
while (input) {
|
|
2876
2585
|
if (/^(\(?10[\^\{])/.test(input)) {
|
|
2877
|
-
var arrows = void 0,
|
|
2878
|
-
expans = void 0,
|
|
2879
|
-
megota = void 0;
|
|
2880
2586
|
/*
|
|
2881
2587
|
10^ - 匹配
|
|
2882
2588
|
10{ - 匹配
|
|
@@ -2887,29 +2593,30 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2887
2593
|
*/
|
|
2888
2594
|
if (input[0] == "(") input = input.substring(1);
|
|
2889
2595
|
//cutted, 10^.... or 10{....
|
|
2596
|
+
var arrows, expans, megota;
|
|
2890
2597
|
if (input[2] == "^") {
|
|
2891
|
-
|
|
2598
|
+
a = input.substring(2).search(/[^\^]/);
|
|
2892
2599
|
//cut input to ^^...^^, and search how numbers
|
|
2893
|
-
arrows =
|
|
2600
|
+
arrows = a;
|
|
2894
2601
|
// 10^^^
|
|
2895
|
-
b =
|
|
2602
|
+
b = a + 2; // b points to after ^'s.
|
|
2896
2603
|
} else {
|
|
2897
2604
|
// 10{...}
|
|
2898
|
-
|
|
2605
|
+
a = input.indexOf("}");
|
|
2899
2606
|
// select contents between {...}
|
|
2900
|
-
var tmp = input.substring(3,
|
|
2607
|
+
var tmp = input.substring(3, a).split(",");
|
|
2901
2608
|
arrows = Number(tmp[0] == "!" ? Infinity : tmp[0]);
|
|
2902
2609
|
expans = Number((_f = tmp[1] == "!" ? Infinity : tmp[1]) !== null && _f !== void 0 ? _f : 1);
|
|
2903
2610
|
megota = Number((_g = tmp[2]) !== null && _g !== void 0 ? _g : 1);
|
|
2904
|
-
b =
|
|
2611
|
+
b = a + 1;
|
|
2905
2612
|
// b points to after }.
|
|
2906
2613
|
}
|
|
2907
2614
|
input = input.substring(b);
|
|
2908
2615
|
if (input[0] == ")") {
|
|
2909
2616
|
// )^....<Space>
|
|
2910
|
-
|
|
2911
|
-
c = Number(input.substring(2,
|
|
2912
|
-
input = input.substring(
|
|
2617
|
+
a = input.indexOf(" ");
|
|
2618
|
+
c = Number(input.substring(2, a)); // Select contents between )^....<Space>
|
|
2619
|
+
input = input.substring(a + 1); // c points to after <Space>
|
|
2913
2620
|
} else {
|
|
2914
2621
|
c = 1; // There is only spaces, count as <ONE>
|
|
2915
2622
|
}
|
|
@@ -2920,21 +2627,21 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2920
2627
|
x.array.splice(1, 0, newOperator(c, 1, expans, megota));
|
|
2921
2628
|
}
|
|
2922
2629
|
} else if (arrows == 2 && expans == 1 && megota == 1) {
|
|
2923
|
-
|
|
2630
|
+
a = x.array.length >= 2 && x.array[1].arrow == 1 ? x.array[1].repeat : 0;
|
|
2924
2631
|
b = x.array[0].repeat;
|
|
2925
|
-
if (b >= 1e10) ++
|
|
2926
|
-
if (b >= 10) ++
|
|
2927
|
-
x.array[0].repeat =
|
|
2632
|
+
if (b >= 1e10) ++a;
|
|
2633
|
+
if (b >= 10) ++a;
|
|
2634
|
+
x.array[0].repeat = a;
|
|
2928
2635
|
if (x.array.length >= 2 && x.array[1].arrow == 1) x.array.splice(1, 1);
|
|
2929
2636
|
d = x.getOperatorIndex(2);
|
|
2930
2637
|
if (Number.isInteger(d)) x.array[d].repeat += c;else x.array.splice(Math.ceil(d), 0, newOperator(c, 2, expans, megota));
|
|
2931
2638
|
} else if (isFinite(arrows)) {
|
|
2932
|
-
|
|
2639
|
+
a = x.getOperator(arrows - 1);
|
|
2933
2640
|
b = x.getOperator(arrows - 2);
|
|
2934
|
-
if (b >= 10) ++
|
|
2641
|
+
if (b >= 10) ++a;
|
|
2935
2642
|
d = x.getOperatorIndex(arrows);
|
|
2936
2643
|
x.array.splice(1, Math.ceil(d) - 1);
|
|
2937
|
-
x.array[0].repeat =
|
|
2644
|
+
x.array[0].repeat = a;
|
|
2938
2645
|
if (Number.isInteger(d)) x.array[1].repeat += c;else x.array.splice(1, 0, newOperator(c, arrows, expans, megota));
|
|
2939
2646
|
} else {
|
|
2940
2647
|
x.array.splice(1, 0, newOperator(c, arrows, expans, megota));
|
|
@@ -2943,10 +2650,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2943
2650
|
break;
|
|
2944
2651
|
}
|
|
2945
2652
|
}
|
|
2946
|
-
|
|
2653
|
+
a = input.split(/[Ee]/);
|
|
2947
2654
|
b = [x.array[0].repeat, 0];
|
|
2948
2655
|
c = 1;
|
|
2949
|
-
for (var
|
|
2656
|
+
for (var _i2 = a.length - 1; _i2 >= 0; --_i2) {
|
|
2950
2657
|
//The things that are already there
|
|
2951
2658
|
if (b[0] < MSI_LOG10 && b[1] === 0) {
|
|
2952
2659
|
b[0] = Math.pow(10, c * b[0]);
|
|
@@ -2963,12 +2670,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2963
2670
|
b[1]++;
|
|
2964
2671
|
}
|
|
2965
2672
|
//Multiplying coefficient
|
|
2966
|
-
var decimalPointPos =
|
|
2967
|
-
var intPartLen = decimalPointPos == -1 ?
|
|
2673
|
+
var decimalPointPos = a[_i2].indexOf(".");
|
|
2674
|
+
var intPartLen = decimalPointPos == -1 ? a[_i2].length : decimalPointPos;
|
|
2968
2675
|
if (b[1] === 0) {
|
|
2969
|
-
if (intPartLen >= LONG_STRING_MIN_LENGTH) b[0] = Math.log10(b[0]) + log10LongString(
|
|
2676
|
+
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]);
|
|
2970
2677
|
} else {
|
|
2971
|
-
d = intPartLen >= LONG_STRING_MIN_LENGTH ? log10LongString(
|
|
2678
|
+
d = intPartLen >= LONG_STRING_MIN_LENGTH ? log10LongString(a[_i2].substring(0, intPartLen)) : a[_i2] ? Math.log10(Number(a[_i2])) : 0;
|
|
2972
2679
|
if (b[1] == 1) {
|
|
2973
2680
|
b[0] += d;
|
|
2974
2681
|
} else if (b[1] == 2 && b[0] < MSI_LOG10 + Math.log10(d)) {
|
|
@@ -2999,17 +2706,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2999
2706
|
key: "fromObject",
|
|
3000
2707
|
value: function fromObject(powlikeObject) {
|
|
3001
2708
|
var obj = new PowiainaNum();
|
|
3002
|
-
obj.resetFromObject({
|
|
3003
|
-
array: [{
|
|
3004
|
-
arrow: 0,
|
|
3005
|
-
expans: 1,
|
|
3006
|
-
megota: 1,
|
|
3007
|
-
repeat: NaN
|
|
3008
|
-
}],
|
|
3009
|
-
small: false,
|
|
3010
|
-
layer: 0,
|
|
3011
|
-
sign: 0
|
|
3012
|
-
});
|
|
3013
2709
|
obj.array = [];
|
|
3014
2710
|
if (isExpantaNumArray(powlikeObject)) {
|
|
3015
2711
|
for (var i = 0; i < powlikeObject.length; i++) {
|
|
@@ -3027,8 +2723,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3027
2723
|
} else if (isPowiainaNum01XArray(powlikeObject)) {
|
|
3028
2724
|
var arrayobj = powlikeObject;
|
|
3029
2725
|
obj.array[0] = newOperator(arrayobj[0]);
|
|
3030
|
-
for (var
|
|
3031
|
-
var b = arrayobj[
|
|
2726
|
+
for (var _i3 = 1; _i3 < arrayobj.length; _i3++) {
|
|
2727
|
+
var b = arrayobj[_i3];
|
|
3032
2728
|
obj.array[1] = newOperator(b[1], replaceXToInfinity(b[0]), replaceXToInfinity(b[2]), b[3]);
|
|
3033
2729
|
}
|
|
3034
2730
|
obj.small = false;
|
|
@@ -3036,21 +2732,21 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3036
2732
|
obj.layer = 0;
|
|
3037
2733
|
return obj;
|
|
3038
2734
|
} else {
|
|
3039
|
-
|
|
2735
|
+
for (var _i4 = 0; _i4 < powlikeObject.array.length; _i4++) {
|
|
2736
|
+
obj.array[_i4] = {
|
|
2737
|
+
arrow: powlikeObject.array[_i4].arrow,
|
|
2738
|
+
expans: powlikeObject.array[_i4].expans,
|
|
2739
|
+
megota: powlikeObject.array[_i4].megota,
|
|
2740
|
+
repeat: powlikeObject.array[_i4].repeat,
|
|
2741
|
+
valuereplaced: powlikeObject.array[_i4].valuereplaced
|
|
2742
|
+
};
|
|
2743
|
+
}
|
|
2744
|
+
obj.small = powlikeObject.small;
|
|
2745
|
+
obj.sign = powlikeObject.sign;
|
|
2746
|
+
obj.layer = powlikeObject.layer;
|
|
3040
2747
|
return obj;
|
|
3041
2748
|
}
|
|
3042
2749
|
}
|
|
3043
|
-
}, {
|
|
3044
|
-
key: "grahalFunction",
|
|
3045
|
-
value: function grahalFunction(layers2) {
|
|
3046
|
-
var layers = new PowiainaNum(layers2);
|
|
3047
|
-
if (!layers.isInt() || layers.lt(0) || layers.isNaN()) return PowiainaNum.NaN.clone();
|
|
3048
|
-
if (layers.eq(1)) return new PowiainaNum("10^^^(10^)^7625597484984 3638334640023.7783");else if (layers.lte(MSI)) {
|
|
3049
|
-
return new PowiainaNum("(10{!})^".concat(layers.toNumber(), " 10^^^(10^)^7625597484984 3638334640023.7783"));
|
|
3050
|
-
} else {
|
|
3051
|
-
return PowiainaNum.BEAF(3, layers, 1, 2);
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
2750
|
}]);
|
|
3055
2751
|
}();
|
|
3056
2752
|
_a = Symbol.toStringTag;
|
|
@@ -3267,14 +2963,5 @@ PowiainaNum.maxOps = 100;
|
|
|
3267
2963
|
PowiainaNum.POW_2_44_MOD_PI = 1.701173079953;
|
|
3268
2964
|
//#endregion
|
|
3269
2965
|
PowiainaNum.arrowFuncMap = new Map();
|
|
3270
|
-
//#region configurations
|
|
3271
|
-
/**
|
|
3272
|
-
* 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.
|
|
3273
|
-
*/
|
|
3274
|
-
PowiainaNum.usingBreakEternityLikeFromString = false;
|
|
3275
|
-
/**
|
|
3276
|
-
* If you set this config to true, the `constructor` method will return Zero instead of NaN when call new PowiainaNum() with no arguments.
|
|
3277
|
-
*/
|
|
3278
|
-
PowiainaNum.blankArgumentConstructorReturnZero = false;
|
|
3279
2966
|
|
|
3280
2967
|
export { arraySortFunction, PowiainaNum as default, mergeSameArrays };
|