powiaina_num.js 0.2.0-alpha.4 → 0.2.0-alpha.4.2
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/README.md +4 -1
- package/dist/PowiainaNum.cjs.js +259 -23
- package/dist/PowiainaNum.esm.js +255 -23
- package/dist/PowiainaNum.js +263 -27
- package/dist/PowiainaNum.min.js +1 -1
- package/dist/index.d.ts +25 -7
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -19,7 +19,10 @@ If arrow count or expans count is Infinite, the count replaces to the next opera
|
|
|
19
19
|
|
|
20
20
|
Some codes snippet from [ExpantaNum.js by Naruyoko](https://github.com/Naruyoko/ExpantaNum.js)
|
|
21
21
|
|
|
22
|
-
Functions are as follows `abs, neg, add, sub, mul, div, rec, pow, pow10, pow_base, sqrt, cbrt, root, log10, log, cmp, rec, gamma, mod, exp, ln, slog, factorial, tetrate_10, isFinite, isInfinite, isNaN, tetrate, lambertw, toString, toJSON, floor, ceil, round, trunc, clampMax, clampMin, arrow, expansion, expansionArrow, multiExpansion, powerExpansion`(some missing items that have not been fully developed)
|
|
22
|
+
Functions are as follows `abs, neg, add, sub, mul, div, rec, pow, pow10, pow_base, sqrt, cbrt, root, log10, log, cmp, rec, gamma, mod, exp, ln, slog, factorial, tetrate_10, isFinite, isInfinite, isNaN, tetrate, lambertw, toString, toJSON, floor, ceil, round, trunc, clampMax, clampMin, arrow, expansion, expansionArrow, multiExpansion, powerExpansion, explosion`(some missing items that have not been fully developed)
|
|
23
|
+
|
|
24
|
+
## Current unstable functions
|
|
25
|
+
`megotion, BEAF`
|
|
23
26
|
|
|
24
27
|
## Using
|
|
25
28
|
|
package/dist/PowiainaNum.cjs.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
function _arrayLikeToArray(r, a) {
|
|
4
6
|
(null == a || a > r.length) && (a = r.length);
|
|
5
7
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -96,7 +98,7 @@ function compareTuples() {
|
|
|
96
98
|
function replaceETo10(str) {
|
|
97
99
|
// 使用正则表达式匹配 (e^数字) 的模式
|
|
98
100
|
// 正则解释:\(e\^(\d+)\) 匹配 (e^数字),其中 \d+ 匹配一个或多个数字
|
|
99
|
-
return str.replace(/\(e\^(\d+)\)/g,
|
|
101
|
+
return str.replace(/\(e\^(\d+)\)/g, "(10^)^$1 ").replace(/(\d+)\x20*PT/g, "(10^)^$1 ");
|
|
100
102
|
}
|
|
101
103
|
/**
|
|
102
104
|
* 把一个字符串很长的数进行以10为底的对数
|
|
@@ -243,6 +245,23 @@ function d_lambertw(z) {
|
|
|
243
245
|
}
|
|
244
246
|
throw Error("Iteration failed to converge: " + z);
|
|
245
247
|
}
|
|
248
|
+
function arraySortFunction(a, b) {
|
|
249
|
+
return compareTuples([a.megota, a.expans, a.arrow], [b.megota, b.expans, b.arrow]);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Merge arrays in arrow,expans,megota is all same.
|
|
253
|
+
* @param x an object has `array` key.
|
|
254
|
+
*/
|
|
255
|
+
function mergeSameArrays(x) {
|
|
256
|
+
for (var i = 1; i < x.array.length - 1; ++i) {
|
|
257
|
+
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) {
|
|
258
|
+
// same array's merge
|
|
259
|
+
x.array[i].repeat += x.array[i + 1].repeat;
|
|
260
|
+
x.array.splice(i + 1, 1);
|
|
261
|
+
--i;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
246
265
|
var PowiainaNum = /*#__PURE__*/function () {
|
|
247
266
|
/**
|
|
248
267
|
* Constructor of PowiainaNum class,
|
|
@@ -314,6 +333,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
314
333
|
b = x;
|
|
315
334
|
a = y;
|
|
316
335
|
}
|
|
336
|
+
var temp = a.toNumber() + b.toNumber();
|
|
337
|
+
if (isFinite(temp) && temp !== 0) {
|
|
338
|
+
return PowiainaNum.fromNumber(temp);
|
|
339
|
+
}
|
|
317
340
|
var mult = 1;
|
|
318
341
|
if (!a.small && !b.small && !((_a = a.array[1]) === null || _a === void 0 ? void 0 : _a.repeat) && !((_b = b.array[1]) === null || _b === void 0 ? void 0 : _b.repeat) && a.sign == b.sign) {
|
|
319
342
|
return new PowiainaNum((a.array[0].repeat + b.array[0].repeat) * a.sign);
|
|
@@ -355,7 +378,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
355
378
|
var y = new PowiainaNum(other);
|
|
356
379
|
// inf * -inf = -inf
|
|
357
380
|
if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || y.eq(PowiainaNum.POSITIVE_INFINITY) && x.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.NEGATIVE_INFINITY.clone();
|
|
358
|
-
if (x.isInfiNaN() && y.
|
|
381
|
+
if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero()) return PowiainaNum.NaN.clone();
|
|
359
382
|
if (x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.POSITIVE_INFINITY.clone();
|
|
360
383
|
// inf & nan check
|
|
361
384
|
if (!x.isFinite()) return x.clone();
|
|
@@ -371,6 +394,11 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
371
394
|
a.sign = x.sign*y.sign as -1|0| 1;
|
|
372
395
|
return a;
|
|
373
396
|
})(); */
|
|
397
|
+
// calculate use number directly using number
|
|
398
|
+
var t = x.toNumber() * y.toNumber();
|
|
399
|
+
if (isFinite(t) && t !== 0) {
|
|
400
|
+
return PowiainaNum.fromNumber(t);
|
|
401
|
+
}
|
|
374
402
|
var r;
|
|
375
403
|
r = x.abs().log10().add(y.abs().log10()).pow10();
|
|
376
404
|
r.sign = x.sign * y.sign;
|
|
@@ -414,6 +442,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
414
442
|
key: "pow",
|
|
415
443
|
value: function pow(x) {
|
|
416
444
|
var other = new PowiainaNum(x);
|
|
445
|
+
if (this.eq(1)) return PowiainaNum.ONE.clone();
|
|
417
446
|
if (!other.isFinite()) return other.clone();
|
|
418
447
|
if (!this.isFinite()) return this.clone();
|
|
419
448
|
if (this.eq(10)) return other.pow10();
|
|
@@ -434,8 +463,19 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
434
463
|
// optimize?
|
|
435
464
|
return PowiainaNum.fromNumber(t);
|
|
436
465
|
}
|
|
437
|
-
|
|
438
|
-
|
|
466
|
+
if (this.isZero() && other.isZero()) {
|
|
467
|
+
return PowiainaNum.ONE.clone();
|
|
468
|
+
}
|
|
469
|
+
if (this.isZero()) return PowiainaNum.ZERO.clone();
|
|
470
|
+
if (other.isZero()) return PowiainaNum.ONE.clone();
|
|
471
|
+
// if this<0, check other' rec is oddd
|
|
472
|
+
if (this.gt(0)) {
|
|
473
|
+
// log10(a^b) = b log10(a)
|
|
474
|
+
return this.log10().mul(other).pow10();
|
|
475
|
+
} else if (other.rec().mod(2).eq(1)) {
|
|
476
|
+
return this.neg().log10().mul(other).pow10().neg();
|
|
477
|
+
}
|
|
478
|
+
return PowiainaNum.NaN.clone();
|
|
439
479
|
}
|
|
440
480
|
}, {
|
|
441
481
|
key: "pow_base",
|
|
@@ -469,6 +509,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
469
509
|
var other = new PowiainaNum(other2);
|
|
470
510
|
var payl = new PowiainaNum(payload);
|
|
471
511
|
if (t.isNaN() || other.isNaN() || payl.isNaN()) return PowiainaNum.NaN.clone();
|
|
512
|
+
if (t.eq(1)) return PowiainaNum.ONE.clone();
|
|
472
513
|
if (payl.neq(PowiainaNum.ONE)) other = other.add(payl.slog(t));
|
|
473
514
|
var negln;
|
|
474
515
|
if (other.isInfi() && other.sign > 0) {
|
|
@@ -695,7 +736,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
695
736
|
* and gamma(x) = (x - 1)! for nonnegative integer x, so the factorial for non-whole numbers is defined using the gamma function.
|
|
696
737
|
*/
|
|
697
738
|
//[Code from break_eternity.js]
|
|
698
|
-
//from HyperCalc source code
|
|
739
|
+
//from HyperCalc source code
|
|
699
740
|
function gamma() {
|
|
700
741
|
if (this.small) {
|
|
701
742
|
return this.rec();
|
|
@@ -743,13 +784,13 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
743
784
|
key: "lambertw",
|
|
744
785
|
value:
|
|
745
786
|
/**
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
787
|
+
* The Lambert W function, also called the omega function or product logarithm, is the solution W(x) === x*e^x.
|
|
788
|
+
* https://en.wikipedia.org/wiki/Lambert_W_function
|
|
789
|
+
*
|
|
790
|
+
* This is a multi-valued function in the complex plane, but only two branches matter for real numbers: the "principal branch" W0, and the "non-principal branch" W_-1.
|
|
791
|
+
* W_0 works for any number >= -1/e, but W_-1 only works for nonpositive numbers >= -1/e.
|
|
792
|
+
* The "principal" parameter, which is true by default, decides which branch we're looking for: W_0 is used if principal is true, W_-1 is used if principal is false.
|
|
793
|
+
*/
|
|
753
794
|
//Code from break_eternity.js
|
|
754
795
|
//Some special values, for testing: https://en.wikipedia.org/wiki/Lambert_W_function#Special_values
|
|
755
796
|
function lambertw() {
|
|
@@ -1025,6 +1066,17 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1025
1066
|
value: function powerExpansion(other) {
|
|
1026
1067
|
return this.expansionArrow(3)(other);
|
|
1027
1068
|
}
|
|
1069
|
+
}, {
|
|
1070
|
+
key: "explosion",
|
|
1071
|
+
value: function explosion(other) {
|
|
1072
|
+
return PowiainaNum.BEAF(this, other, 1, 3);
|
|
1073
|
+
}
|
|
1074
|
+
}, {
|
|
1075
|
+
key: "megotion",
|
|
1076
|
+
value: function megotion(other) {
|
|
1077
|
+
console.warn("This function is unstable when calculating numbers");
|
|
1078
|
+
return PowiainaNum.BEAF(this, other, 1, 1, 2);
|
|
1079
|
+
}
|
|
1028
1080
|
}, {
|
|
1029
1081
|
key: "max",
|
|
1030
1082
|
value: function max() {
|
|
@@ -1074,6 +1126,47 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1074
1126
|
var other = new PowiainaNum(x).abs();
|
|
1075
1127
|
return this.abs().cmp(other);
|
|
1076
1128
|
}
|
|
1129
|
+
}, {
|
|
1130
|
+
key: "sin",
|
|
1131
|
+
value: function sin() {
|
|
1132
|
+
var x = this.clone();
|
|
1133
|
+
if (x.isneg()) {
|
|
1134
|
+
return x.neg().sin().neg();
|
|
1135
|
+
}
|
|
1136
|
+
var y = x.mod(7074237752028440);
|
|
1137
|
+
return PowiainaNum.fromNumber(Math.sin(y.toNumber()));
|
|
1138
|
+
}
|
|
1139
|
+
}, {
|
|
1140
|
+
key: "cos",
|
|
1141
|
+
value: function cos() {
|
|
1142
|
+
return this.sub(Math.PI / 2).sin();
|
|
1143
|
+
}
|
|
1144
|
+
}, {
|
|
1145
|
+
key: "tan",
|
|
1146
|
+
value: function tan() {
|
|
1147
|
+
return this.sin().div(this.cos());
|
|
1148
|
+
}
|
|
1149
|
+
}, {
|
|
1150
|
+
key: "cot",
|
|
1151
|
+
value: function cot() {
|
|
1152
|
+
return this.cos().div(this.sin());
|
|
1153
|
+
}
|
|
1154
|
+
}, {
|
|
1155
|
+
key: "sec",
|
|
1156
|
+
value: function sec() {
|
|
1157
|
+
return this.cos().rec();
|
|
1158
|
+
}
|
|
1159
|
+
}, {
|
|
1160
|
+
key: "csc",
|
|
1161
|
+
value: function csc() {
|
|
1162
|
+
return this.sin().rec();
|
|
1163
|
+
}
|
|
1164
|
+
// public asin_abs(): PowiainaNum {
|
|
1165
|
+
// const t = this.clone().abs();
|
|
1166
|
+
// if (t.lte(1)) {
|
|
1167
|
+
// return PowiainaNum.fromNumber(Math.asin(t.toNumber()));
|
|
1168
|
+
// }
|
|
1169
|
+
// }
|
|
1077
1170
|
}, {
|
|
1078
1171
|
key: "neg",
|
|
1079
1172
|
value: function neg() {
|
|
@@ -1328,9 +1421,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1328
1421
|
do {
|
|
1329
1422
|
renormalize = false;
|
|
1330
1423
|
// Sort arrays.
|
|
1331
|
-
this.array.sort(
|
|
1332
|
-
return compareTuples([a.megota, a.expans, a.arrow], [b.megota, b.expans, b.arrow]);
|
|
1333
|
-
});
|
|
1424
|
+
this.array.sort(arraySortFunction);
|
|
1334
1425
|
for (i = 1; i < x.array.length - 1; ++i) {
|
|
1335
1426
|
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) {
|
|
1336
1427
|
// same array's merge
|
|
@@ -1374,7 +1465,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1374
1465
|
renormalize = true;
|
|
1375
1466
|
}
|
|
1376
1467
|
while (x.array.length >= 2 && x.array[0].repeat == 1 && x.array[1].repeat) {
|
|
1377
|
-
// for any 10{X}10{X} 1, turn into 10{X}10
|
|
1468
|
+
// for any 10{X}10{X} 1, turn into 10{X}10
|
|
1378
1469
|
// [1, [R=sth, A=sth, E=sth, M=sth]]
|
|
1379
1470
|
if (x.array[1].repeat > 1) {
|
|
1380
1471
|
x.array[1].repeat--;
|
|
@@ -1718,6 +1809,146 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1718
1809
|
value: function powerExpansion(t, other) {
|
|
1719
1810
|
return new PowiainaNum(t).powerExpansion(other);
|
|
1720
1811
|
}
|
|
1812
|
+
}, {
|
|
1813
|
+
key: "BEAF",
|
|
1814
|
+
value: function BEAF(base2, power2) {
|
|
1815
|
+
for (var _len6 = arguments.length, args = new Array(_len6 > 2 ? _len6 - 2 : 0), _key6 = 2; _key6 < _len6; _key6++) {
|
|
1816
|
+
args[_key6 - 2] = arguments[_key6];
|
|
1817
|
+
}
|
|
1818
|
+
console.warn("This function is unstable when calculating numbers greater than *megotion*");
|
|
1819
|
+
var base = new PowiainaNum(base2);
|
|
1820
|
+
var power = new PowiainaNum(power2);
|
|
1821
|
+
function readArg(a) {
|
|
1822
|
+
var _a;
|
|
1823
|
+
return new PowiainaNum((_a = args[a]) !== null && _a !== void 0 ? _a : 1);
|
|
1824
|
+
}
|
|
1825
|
+
if (base.eq(1)) return new PowiainaNum(1);
|
|
1826
|
+
if (power.eq(1)) return new PowiainaNum(base);
|
|
1827
|
+
if (power.isZero()) return new PowiainaNum(1);
|
|
1828
|
+
if (base.lt(0)) return PowiainaNum.NaN.clone();
|
|
1829
|
+
// check infinite
|
|
1830
|
+
var sufpowiaina = args.slice(4);
|
|
1831
|
+
if (sufpowiaina.filter(function (f) {
|
|
1832
|
+
return new PowiainaNum(f).gte(2);
|
|
1833
|
+
}).length > 0) {
|
|
1834
|
+
return PowiainaNum.POSITIVE_INFINITY;
|
|
1835
|
+
}
|
|
1836
|
+
if (readArg(0).eq(1) && readArg(1).eq(1) && readArg(2).eq(1)) {
|
|
1837
|
+
return base.pow(power);
|
|
1838
|
+
}
|
|
1839
|
+
if (readArg(0).eq(2) && readArg(1).eq(1) && readArg(2).eq(1)) {
|
|
1840
|
+
return base.tetrate(power);
|
|
1841
|
+
}
|
|
1842
|
+
if (readArg(1).eq(1) && readArg(2).eq(1)) {
|
|
1843
|
+
return base.arrow(readArg(0))(power);
|
|
1844
|
+
}
|
|
1845
|
+
if (readArg(1).eq(2) && readArg(2).eq(1)) {
|
|
1846
|
+
return base.expansionArrow(readArg(0))(power);
|
|
1847
|
+
}
|
|
1848
|
+
readArg(0).toNumber();
|
|
1849
|
+
var expans = readArg(1);
|
|
1850
|
+
var megota = readArg(2);
|
|
1851
|
+
function convertOperator(arrows, expans, megota) {
|
|
1852
|
+
var a = arrows;
|
|
1853
|
+
var e = expans;
|
|
1854
|
+
var m = megota;
|
|
1855
|
+
if (a == 0 && e > 1) {
|
|
1856
|
+
return [1 / 0, e - 1, m];
|
|
1857
|
+
}
|
|
1858
|
+
if (a == 0 && e == 1 && m > 1) {
|
|
1859
|
+
return [1, 1 / 0, m - 1];
|
|
1860
|
+
}
|
|
1861
|
+
return [a, e, m];
|
|
1862
|
+
}
|
|
1863
|
+
if (megota.gt(MSI)) {
|
|
1864
|
+
throw new Error("Not implemented megota > MSI");
|
|
1865
|
+
}
|
|
1866
|
+
function infToBang(x) {
|
|
1867
|
+
if (!isFinite(x)) return "!";
|
|
1868
|
+
return x.toString();
|
|
1869
|
+
}
|
|
1870
|
+
function getMSIForm(arrow, expans, megota) {
|
|
1871
|
+
return "10{".concat(infToBang(arrow), ",").concat(infToBang(expans), ",").concat(megota, "}").concat(MSI);
|
|
1872
|
+
}
|
|
1873
|
+
var t = base.clone();
|
|
1874
|
+
var arrows = new PowiainaNum(readArg(0));
|
|
1875
|
+
return function (other2, _r, _r2) {
|
|
1876
|
+
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1877
|
+
var other = new PowiainaNum(other2);
|
|
1878
|
+
var r;
|
|
1879
|
+
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
|
|
1880
|
+
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
|
|
1881
|
+
if (t.eq(PowiainaNum.ZERO)) {
|
|
1882
|
+
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
|
|
1883
|
+
return PowiainaNum.NaN.clone();
|
|
1884
|
+
}
|
|
1885
|
+
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
|
|
1886
|
+
if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE.clone();
|
|
1887
|
+
if (other.eq(PowiainaNum.ONE)) return t.clone();
|
|
1888
|
+
if (arrows.eq(0)) {
|
|
1889
|
+
return PowiainaNum.BEAF(t, t, power, expans.sub(1), megota);
|
|
1890
|
+
// {this, this, power, expans-1, megota}
|
|
1891
|
+
}
|
|
1892
|
+
if (expans.eq(0)) {
|
|
1893
|
+
return PowiainaNum.BEAF(t, t, t, power, megota.sub(1));
|
|
1894
|
+
}
|
|
1895
|
+
// expans > 9e15, that using 10{?, x}, x=expans;
|
|
1896
|
+
if (expans.gt(MSI)) {
|
|
1897
|
+
r = new PowiainaNum(expans);
|
|
1898
|
+
r.setOperator(r.getOperator(1, Infinity, megota.toNumber()) + 1, 1, Infinity, megota.toNumber());
|
|
1899
|
+
return r;
|
|
1900
|
+
}
|
|
1901
|
+
// arrow > 9e15, that using 10{x,2}, x=arrow;
|
|
1902
|
+
if (arrows.gt(PowiainaNum.MSI)) {
|
|
1903
|
+
r = arrows.clone();
|
|
1904
|
+
r.setOperator(r.getOperator(Infinity, expans.toNumber(), megota.toNumber()) + 1, Infinity, expans.toNumber(), megota.toNumber());
|
|
1905
|
+
return r;
|
|
1906
|
+
}
|
|
1907
|
+
var arrowsNum = arrows.toNumber();
|
|
1908
|
+
// arrow < 9e15
|
|
1909
|
+
// 10{x}2 = 10{x-1}10
|
|
1910
|
+
if (other.eq(2)) return PowiainaNum.BEAF(t, t, arrowsNum - 1, expans, megota);
|
|
1911
|
+
if (t.max(other).gt(getMSIForm(arrowsNum + 1, expans.toNumber(), megota.toNumber()))) return t.max(other);
|
|
1912
|
+
if (t.gt(getMSIForm(arrowsNum, expans.toNumber(), megota.toNumber())) || other.gt(MSI)) {
|
|
1913
|
+
if (t.gt(getMSIForm(arrowsNum, expans.toNumber(), megota.toNumber()))) {
|
|
1914
|
+
r = t.clone();
|
|
1915
|
+
r.setOperator(r.getOperator(arrowsNum, expans.toNumber(), megota.toNumber()) - 1, arrowsNum, expans.toNumber(), megota.toNumber());
|
|
1916
|
+
r.normalize();
|
|
1917
|
+
} else if (t.gt(getMSIForm.apply(void 0, _toConsumableArray(convertOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber()))))) {
|
|
1918
|
+
r = new PowiainaNum(t.getOperator.apply(t, _toConsumableArray(convertOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber()))));
|
|
1919
|
+
} else {
|
|
1920
|
+
r = PowiainaNum.ZERO;
|
|
1921
|
+
}
|
|
1922
|
+
var j = r.add(other);
|
|
1923
|
+
j.setOperator(j.getOperator(arrowsNum, expans.toNumber(), megota.toNumber()) + 1, arrowsNum, expans.toNumber(), megota.toNumber());
|
|
1924
|
+
j.normalize();
|
|
1925
|
+
return j;
|
|
1926
|
+
}
|
|
1927
|
+
if (depth >= PowiainaNum.maxOps + 10) {
|
|
1928
|
+
return new PowiainaNum({
|
|
1929
|
+
small: false,
|
|
1930
|
+
sign: 1,
|
|
1931
|
+
layer: 0,
|
|
1932
|
+
array: [newOperator(10, 0), newOperator(1, arrowsNum, expans.toNumber(), megota.toNumber())]
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
var y = other.toNumber();
|
|
1936
|
+
var f = Math.floor(y);
|
|
1937
|
+
var arrows_m1 = arrows.sub(PowiainaNum.ONE);
|
|
1938
|
+
r = PowiainaNum.BEAF(t, y - f, arrows_m1.toNumber(), expans, megota);
|
|
1939
|
+
var i = 0;
|
|
1940
|
+
for (var m = new PowiainaNum(getMSIForm.apply(void 0, _toConsumableArray(convertOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber())))); f !== 0 && r.lt(m) && i < 100; i++) {
|
|
1941
|
+
if (f > 0) {
|
|
1942
|
+
r = PowiainaNum.BEAF(base, r, arrows_m1.toNumber(), expans, megota);
|
|
1943
|
+
--f;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
if (i == 100) f = 0;
|
|
1947
|
+
(_r = r).setOperator.apply(_r, [(_r2 = r).getOperator.apply(_r2, _toConsumableArray(convertOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber()))) + f].concat(_toConsumableArray(convertOperator(arrowsNum - 1, expans.toNumber(), megota.toNumber()))));
|
|
1948
|
+
r.normalize();
|
|
1949
|
+
return r;
|
|
1950
|
+
}(power);
|
|
1951
|
+
}
|
|
1721
1952
|
/**
|
|
1722
1953
|
* Select the largest number of arguments.
|
|
1723
1954
|
*/
|
|
@@ -1725,8 +1956,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1725
1956
|
key: "max",
|
|
1726
1957
|
value: function max() {
|
|
1727
1958
|
var max = PowiainaNum.NEGATIVE_INFINITY;
|
|
1728
|
-
for (var
|
|
1729
|
-
args[
|
|
1959
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
1960
|
+
args[_key7] = arguments[_key7];
|
|
1730
1961
|
}
|
|
1731
1962
|
for (var i = 0; i < args.length; i++) {
|
|
1732
1963
|
if (max.lt(args[i])) {
|
|
@@ -1742,8 +1973,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1742
1973
|
key: "min",
|
|
1743
1974
|
value: function min() {
|
|
1744
1975
|
var max = PowiainaNum.POSITIVE_INFINITY;
|
|
1745
|
-
for (var
|
|
1746
|
-
args[
|
|
1976
|
+
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
1977
|
+
args[_key8] = arguments[_key8];
|
|
1747
1978
|
}
|
|
1748
1979
|
for (var i = 0; i < args.length; i++) {
|
|
1749
1980
|
if (max.gt(args[i])) {
|
|
@@ -1801,7 +2032,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1801
2032
|
return obj;
|
|
1802
2033
|
} else if (x > 0) obj.sign = 1;
|
|
1803
2034
|
var y = Math.abs(x);
|
|
1804
|
-
if (y
|
|
2035
|
+
if (y == Infinity) {
|
|
2036
|
+
obj.array = [newOperator(Infinity, 0)];
|
|
2037
|
+
} else if (y >= MSI_REC && y < 1) {
|
|
1805
2038
|
obj.small = true;
|
|
1806
2039
|
obj.array = [newOperator(1 / y, 0)];
|
|
1807
2040
|
} else if (y < MSI_REC) {
|
|
@@ -2000,7 +2233,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2000
2233
|
}
|
|
2001
2234
|
x.array[0].repeat = b[0];
|
|
2002
2235
|
if (b[1]) {
|
|
2003
|
-
if (x.array.length >= 2 && x.array[1].arrow == 1) x.array[1].repeat += b[1];else x.array.splice(1, 0, newOperator(b[1], 1, 1, 1));
|
|
2236
|
+
if (x.array.length >= 2 && x.array[1].arrow == 1 && x.array[1].expans == 1 && x.array[1].megota == 1) x.array[1].repeat += b[1];else x.array.splice(1, 0, newOperator(b[1], 1, 1, 1));
|
|
2004
2237
|
}
|
|
2005
2238
|
}
|
|
2006
2239
|
if (negateIt) x.sign *= -1;
|
|
@@ -2235,5 +2468,8 @@ PowiainaNum.SQRT1_2 = new PowiainaNum(Math.SQRT1_2);
|
|
|
2235
2468
|
PowiainaNum.SQRT2 = new PowiainaNum(Math.SQRT2);
|
|
2236
2469
|
PowiainaNum.maxOps = 100;
|
|
2237
2470
|
PowiainaNum.arrowFuncMap = new Map();
|
|
2471
|
+
PowiainaNum.POW_2_44_MOD_PI = 1.701173079953;
|
|
2238
2472
|
|
|
2239
|
-
|
|
2473
|
+
exports.arraySortFunction = arraySortFunction;
|
|
2474
|
+
exports["default"] = PowiainaNum;
|
|
2475
|
+
exports.mergeSameArrays = mergeSameArrays;
|