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