powiaina_num.js 0.2.0-alpha.2.5 → 0.2.0-alpha.2.7
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 +71 -71
- package/dist/PowiainaNum.cjs.js +86 -10
- package/dist/PowiainaNum.esm.js +86 -10
- package/dist/PowiainaNum.js +86 -10
- package/dist/PowiainaNum.min.js +1 -1
- package/dist/index.d.ts +4 -0
- package/package.json +47 -47
package/README.md
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
# PowiainaNum.js
|
|
2
|
-
|
|
3
|
-
A JavaScript library that handles arithmetic for numbers as large as {10,9e15,1,1,1,2}.
|
|
4
|
-
|
|
5
|
-
This reaches level f<sub>ω<sup>3</sup>+1</sub>.
|
|
6
|
-
|
|
7
|
-
Internally, it is represented as an sign,layer, small and array. Sign is 1 or -1. It's 10{oper.arrow, oper.expans, oper.megota}, If arrow count or expans count is Infinite, the count replaces from the next operators.
|
|
8
|
-
|
|
9
|
-
Some codes snippet from [ExpantaNum.js by Naruyoko](https://github.com/Naruyoko/ExpantaNum.js)
|
|
10
|
-
|
|
11
|
-
Functions are as follows `abs, neg, add, sub, mul, div, rec, pow, sqrt, cbrt, root, log10, log, cmp, isFinite, isInfinite, isNaN`(some missing items that have not been fully developed)
|
|
12
|
-
|
|
13
|
-
## Using
|
|
14
|
-
|
|
15
|
-
The library exports a class,
|
|
16
|
-
Create a PowiainaNum.js object like this:
|
|
17
|
-
|
|
18
|
-
```javascript
|
|
19
|
-
import PowiainaNum from "powiaina_num.js";
|
|
20
|
-
|
|
21
|
-
let a = new PowiainaNum(); // create PN.js number with NaN
|
|
22
|
-
let b = new PowiainaNum(3); // create PN.js number with number 3
|
|
23
|
-
let c = new PowiainaNum("1e114514"); // create PN.js number with number 10^114514
|
|
24
|
-
|
|
25
|
-
let d = new PowiainaNum(c); // create PN.js number from a PN.js number
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Javascript operators will not work such as `+`, `-`, etc.
|
|
29
|
-
You should call the equivalent functions instead.
|
|
30
|
-
|
|
31
|
-
```javascript
|
|
32
|
-
let a = new PowiainaNum(114514);
|
|
33
|
-
let b = new PowiainaNum(1919810);
|
|
34
|
-
|
|
35
|
-
// Calculate a+b:
|
|
36
|
-
let c = a.add(b); // 1919810+114514
|
|
37
|
-
|
|
38
|
-
// Calculate a-b:
|
|
39
|
-
let c = a.sub(b);
|
|
40
|
-
|
|
41
|
-
a.mul(b); // a*b
|
|
42
|
-
a.div(b); // a/b
|
|
43
|
-
a.pow(b); // a^b
|
|
44
|
-
|
|
45
|
-
a.log10(); // log10(a)
|
|
46
|
-
|
|
47
|
-
// comparing PN.js numbers
|
|
48
|
-
|
|
49
|
-
a.lt(b); // a is less than b
|
|
50
|
-
a.gt(b); // a is greater than b
|
|
51
|
-
a.eq(b); // a is equals to b
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Future ideas
|
|
55
|
-
|
|
56
|
-
Extend `Operator` to nearly infinite keys to reach level f<sub>ω<sup>ω</sup></sub>
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
interface Operator {
|
|
60
|
-
/*P3*/ arrow: number;
|
|
61
|
-
/*P4*/ expans: number;
|
|
62
|
-
/*P5*/ megota: number;
|
|
63
|
-
/*P6*/ powiaina: number;
|
|
64
|
-
P7: number;
|
|
65
|
-
.....
|
|
66
|
-
|
|
67
|
-
repeat: number;
|
|
68
|
-
|
|
69
|
-
valuereplaced?: -1 | 0 | 1 | 2 | ...
|
|
70
|
-
}
|
|
71
|
-
```
|
|
1
|
+
# PowiainaNum.js
|
|
2
|
+
|
|
3
|
+
A JavaScript library that handles arithmetic for numbers as large as {10,9e15,1,1,1,2}.
|
|
4
|
+
|
|
5
|
+
This reaches level f<sub>ω<sup>3</sup>+1</sub>.
|
|
6
|
+
|
|
7
|
+
Internally, it is represented as an sign,layer, small and array. Sign is 1 or -1. It's 10{oper.arrow, oper.expans, oper.megota}, If arrow count or expans count is Infinite, the count replaces from the next operators.
|
|
8
|
+
|
|
9
|
+
Some codes snippet from [ExpantaNum.js by Naruyoko](https://github.com/Naruyoko/ExpantaNum.js)
|
|
10
|
+
|
|
11
|
+
Functions are as follows `abs, neg, add, sub, mul, div, rec, pow, sqrt, cbrt, root, log10, log, cmp, isFinite, isInfinite, isNaN`(some missing items that have not been fully developed)
|
|
12
|
+
|
|
13
|
+
## Using
|
|
14
|
+
|
|
15
|
+
The library exports a class,
|
|
16
|
+
Create a PowiainaNum.js object like this:
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
import PowiainaNum from "powiaina_num.js";
|
|
20
|
+
|
|
21
|
+
let a = new PowiainaNum(); // create PN.js number with NaN
|
|
22
|
+
let b = new PowiainaNum(3); // create PN.js number with number 3
|
|
23
|
+
let c = new PowiainaNum("1e114514"); // create PN.js number with number 10^114514
|
|
24
|
+
|
|
25
|
+
let d = new PowiainaNum(c); // create PN.js number from a PN.js number
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Javascript operators will not work such as `+`, `-`, etc.
|
|
29
|
+
You should call the equivalent functions instead.
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
let a = new PowiainaNum(114514);
|
|
33
|
+
let b = new PowiainaNum(1919810);
|
|
34
|
+
|
|
35
|
+
// Calculate a+b:
|
|
36
|
+
let c = a.add(b); // 1919810+114514
|
|
37
|
+
|
|
38
|
+
// Calculate a-b:
|
|
39
|
+
let c = a.sub(b);
|
|
40
|
+
|
|
41
|
+
a.mul(b); // a*b
|
|
42
|
+
a.div(b); // a/b
|
|
43
|
+
a.pow(b); // a^b
|
|
44
|
+
|
|
45
|
+
a.log10(); // log10(a)
|
|
46
|
+
|
|
47
|
+
// comparing PN.js numbers
|
|
48
|
+
|
|
49
|
+
a.lt(b); // a is less than b
|
|
50
|
+
a.gt(b); // a is greater than b
|
|
51
|
+
a.eq(b); // a is equals to b
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Future ideas
|
|
55
|
+
|
|
56
|
+
Extend `Operator` to nearly infinite keys to reach level f<sub>ω<sup>ω</sup></sub>
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
interface Operator {
|
|
60
|
+
/*P3*/ arrow: number;
|
|
61
|
+
/*P4*/ expans: number;
|
|
62
|
+
/*P5*/ megota: number;
|
|
63
|
+
/*P6*/ powiaina: number;
|
|
64
|
+
P7: number;
|
|
65
|
+
.....
|
|
66
|
+
|
|
67
|
+
repeat: number;
|
|
68
|
+
|
|
69
|
+
valuereplaced?: -1 | 0 | 1 | 2 | ...
|
|
70
|
+
}
|
|
71
|
+
```
|
package/dist/PowiainaNum.cjs.js
CHANGED
|
@@ -276,7 +276,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
276
276
|
if (l > MSI_LOG10 || l < -MSI_LOG10) {
|
|
277
277
|
r.array = [newOperator(l, 0), newOperator(1, 1)];
|
|
278
278
|
} else {
|
|
279
|
-
r.array = [newOperator(Math.pow(10, l), 0)];
|
|
279
|
+
r.array = [newOperator(Math.pow(10, Math.abs(l)), 0)];
|
|
280
280
|
}
|
|
281
281
|
r.small = l < 0 ? true : false;
|
|
282
282
|
r.sign *= mult;
|
|
@@ -333,6 +333,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
333
333
|
r.sign *= -1;
|
|
334
334
|
return r.pow10().rec();
|
|
335
335
|
}
|
|
336
|
+
if (r.lte(308.25471555991675)) {
|
|
337
|
+
return PowiainaNum.fromNumber(Math.pow(10, r.toNumber()));
|
|
338
|
+
}
|
|
336
339
|
if (r.small) {
|
|
337
340
|
if (r.lt(PowiainaNum.MSI_REC)) return PowiainaNum.ONE;
|
|
338
341
|
return new PowiainaNum(Math.pow(10, Math.pow(r.array[0].repeat, -1)));
|
|
@@ -359,9 +362,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
359
362
|
return r;
|
|
360
363
|
}
|
|
361
364
|
var a = this.toNumber();
|
|
362
|
-
var b =
|
|
365
|
+
var b = other.toNumber();
|
|
363
366
|
var t = Math.pow(a, b);
|
|
364
|
-
if (
|
|
367
|
+
if (isFinite(t)) {
|
|
365
368
|
// optimize?
|
|
366
369
|
return PowiainaNum.fromNumber(t);
|
|
367
370
|
}
|
|
@@ -407,9 +410,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
407
410
|
_x.small = !_x.small;
|
|
408
411
|
return _x.log10().neg();
|
|
409
412
|
}
|
|
410
|
-
if (this.
|
|
413
|
+
if (this.array.length == 1) return new PowiainaNum(Math.log10(this.array[0].repeat));
|
|
411
414
|
var x = this.clone();
|
|
412
|
-
x.
|
|
415
|
+
x.array[1].repeat = x.array[1].repeat - 1;
|
|
413
416
|
x.normalize();
|
|
414
417
|
return x;
|
|
415
418
|
}
|
|
@@ -627,6 +630,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
627
630
|
r.sign = this.sign;
|
|
628
631
|
return r;
|
|
629
632
|
}
|
|
633
|
+
}, {
|
|
634
|
+
key: "trunc",
|
|
635
|
+
value: function trunc() {
|
|
636
|
+
var y = this.clone();
|
|
637
|
+
return y.gte(0) ? y.floor() : y.ceil();
|
|
638
|
+
}
|
|
630
639
|
/**
|
|
631
640
|
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
632
641
|
*/
|
|
@@ -959,7 +968,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
959
968
|
value: function toNumber() {
|
|
960
969
|
if (this.sign == -1) return -this.neg().toNumber();
|
|
961
970
|
if (this.small) return 1 / this.rec().toNumber();
|
|
962
|
-
if (this.
|
|
971
|
+
if (this.array.length > 2) return Infinity;
|
|
972
|
+
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));
|
|
963
973
|
return NaN;
|
|
964
974
|
}
|
|
965
975
|
}, {
|
|
@@ -1087,6 +1097,30 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1087
1097
|
var principal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1088
1098
|
return new PowiainaNum(x).lambertw(principal);
|
|
1089
1099
|
}
|
|
1100
|
+
}, {
|
|
1101
|
+
key: "tetrate_10",
|
|
1102
|
+
value: function tetrate_10(other2) {
|
|
1103
|
+
var other = new PowiainaNum(other2);
|
|
1104
|
+
var height_int = other.trunc().toNumber();
|
|
1105
|
+
var height_frac = other.sub(height_int).toNumber();
|
|
1106
|
+
if (other.gt(PowiainaNum.PENTATED_MSI)) return other.clone();else if (other.gt(PowiainaNum.MSI)) {
|
|
1107
|
+
other.setOperator(other.getOperator(2) + 1, 2);
|
|
1108
|
+
} else if (other.lt(-2)) return PowiainaNum.NaN.clone();else if (other.lt(-1)) {
|
|
1109
|
+
return other.add(2).log10();
|
|
1110
|
+
} else if (other.lt(0)) {
|
|
1111
|
+
return other.add(1);
|
|
1112
|
+
} else if (other.lt(1)) {
|
|
1113
|
+
return other.pow10(); // 10^x
|
|
1114
|
+
} else if (height_int == 1) return PowiainaNum.pow(10, PowiainaNum.pow(10, height_frac));else if (height_int == 2) return PowiainaNum.pow(10, PowiainaNum.pow(10, PowiainaNum.pow(10, height_frac)));else {
|
|
1115
|
+
var remain = height_int - 2;
|
|
1116
|
+
var a = PowiainaNum.pow(10, PowiainaNum.pow(10, PowiainaNum.pow(10, height_frac)));
|
|
1117
|
+
a.setOperator(a.getOperator(1) + remain, 1);
|
|
1118
|
+
return a;
|
|
1119
|
+
}
|
|
1120
|
+
// 1--2, 10-<1e10, 10^10^0->1
|
|
1121
|
+
// 2--3, 1e10-<e1e10, 10^10^10^0->1
|
|
1122
|
+
return PowiainaNum.NaN.clone();
|
|
1123
|
+
}
|
|
1090
1124
|
}, {
|
|
1091
1125
|
key: "isNaN",
|
|
1092
1126
|
value: function isNaN(x) {
|
|
@@ -1097,7 +1131,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1097
1131
|
value: function fromNumber(x) {
|
|
1098
1132
|
var obj = new PowiainaNum(); // NaN
|
|
1099
1133
|
if (x < 0) obj.sign = -1; // negative
|
|
1100
|
-
else if (x == 0)
|
|
1134
|
+
else if (x == 0) {
|
|
1135
|
+
obj.sign = 0;
|
|
1136
|
+
obj.small = true;
|
|
1137
|
+
obj.array = [newOperator(Infinity, 0)];
|
|
1138
|
+
return obj;
|
|
1139
|
+
} else if (x > 0) obj.sign = 1;
|
|
1101
1140
|
var y = Math.abs(x);
|
|
1102
1141
|
if (y >= MSI_REC && y < 1) {
|
|
1103
1142
|
obj.small = true;
|
|
@@ -1117,9 +1156,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1117
1156
|
key: "fromString",
|
|
1118
1157
|
value: function fromString(input) {
|
|
1119
1158
|
var _a, _b, _c, _d, _e, _f;
|
|
1120
|
-
if (!isPowiainaNum.test(input)) {
|
|
1121
|
-
throw powiainaNumError + "malformed input: " + input;
|
|
1122
|
-
}
|
|
1123
1159
|
var x = new PowiainaNum();
|
|
1124
1160
|
// Judge the string was a number
|
|
1125
1161
|
// @ts-ignore
|
|
@@ -1130,6 +1166,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1130
1166
|
return x;
|
|
1131
1167
|
}
|
|
1132
1168
|
}
|
|
1169
|
+
if (!isPowiainaNum.test(input)) {
|
|
1170
|
+
throw powiainaNumError + "malformed input: " + input;
|
|
1171
|
+
}
|
|
1133
1172
|
var negateIt = false;
|
|
1134
1173
|
var recipIt = false;
|
|
1135
1174
|
if (input[0] == "-" || input[0] == "+") {
|
|
@@ -1350,6 +1389,43 @@ PowiainaNum.E_MSI_REC = new PowiainaNum({
|
|
|
1350
1389
|
layer: 0,
|
|
1351
1390
|
sign: 1
|
|
1352
1391
|
});
|
|
1392
|
+
PowiainaNum.TETRATED_MSI = new PowiainaNum({
|
|
1393
|
+
array: [{
|
|
1394
|
+
arrow: 0,
|
|
1395
|
+
expans: 1,
|
|
1396
|
+
megota: 1,
|
|
1397
|
+
repeat: MSI
|
|
1398
|
+
}, {
|
|
1399
|
+
arrow: 1,
|
|
1400
|
+
expans: 1,
|
|
1401
|
+
megota: 1,
|
|
1402
|
+
repeat: MSI
|
|
1403
|
+
}],
|
|
1404
|
+
small: false,
|
|
1405
|
+
layer: 0,
|
|
1406
|
+
sign: 1
|
|
1407
|
+
});
|
|
1408
|
+
PowiainaNum.PENTATED_MSI = new PowiainaNum({
|
|
1409
|
+
array: [{
|
|
1410
|
+
arrow: 0,
|
|
1411
|
+
expans: 1,
|
|
1412
|
+
megota: 1,
|
|
1413
|
+
repeat: MSI
|
|
1414
|
+
}, {
|
|
1415
|
+
arrow: 1,
|
|
1416
|
+
expans: 1,
|
|
1417
|
+
megota: 1,
|
|
1418
|
+
repeat: MSI
|
|
1419
|
+
}, {
|
|
1420
|
+
arrow: 2,
|
|
1421
|
+
expans: 1,
|
|
1422
|
+
megota: 1,
|
|
1423
|
+
repeat: MSI
|
|
1424
|
+
}],
|
|
1425
|
+
small: false,
|
|
1426
|
+
layer: 0,
|
|
1427
|
+
sign: 1
|
|
1428
|
+
});
|
|
1353
1429
|
PowiainaNum.TRITRI = new PowiainaNum({
|
|
1354
1430
|
small: false,
|
|
1355
1431
|
layer: 0,
|
package/dist/PowiainaNum.esm.js
CHANGED
|
@@ -274,7 +274,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
274
274
|
if (l > MSI_LOG10 || l < -MSI_LOG10) {
|
|
275
275
|
r.array = [newOperator(l, 0), newOperator(1, 1)];
|
|
276
276
|
} else {
|
|
277
|
-
r.array = [newOperator(Math.pow(10, l), 0)];
|
|
277
|
+
r.array = [newOperator(Math.pow(10, Math.abs(l)), 0)];
|
|
278
278
|
}
|
|
279
279
|
r.small = l < 0 ? true : false;
|
|
280
280
|
r.sign *= mult;
|
|
@@ -331,6 +331,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
331
331
|
r.sign *= -1;
|
|
332
332
|
return r.pow10().rec();
|
|
333
333
|
}
|
|
334
|
+
if (r.lte(308.25471555991675)) {
|
|
335
|
+
return PowiainaNum.fromNumber(Math.pow(10, r.toNumber()));
|
|
336
|
+
}
|
|
334
337
|
if (r.small) {
|
|
335
338
|
if (r.lt(PowiainaNum.MSI_REC)) return PowiainaNum.ONE;
|
|
336
339
|
return new PowiainaNum(Math.pow(10, Math.pow(r.array[0].repeat, -1)));
|
|
@@ -357,9 +360,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
357
360
|
return r;
|
|
358
361
|
}
|
|
359
362
|
var a = this.toNumber();
|
|
360
|
-
var b =
|
|
363
|
+
var b = other.toNumber();
|
|
361
364
|
var t = Math.pow(a, b);
|
|
362
|
-
if (
|
|
365
|
+
if (isFinite(t)) {
|
|
363
366
|
// optimize?
|
|
364
367
|
return PowiainaNum.fromNumber(t);
|
|
365
368
|
}
|
|
@@ -405,9 +408,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
405
408
|
_x.small = !_x.small;
|
|
406
409
|
return _x.log10().neg();
|
|
407
410
|
}
|
|
408
|
-
if (this.
|
|
411
|
+
if (this.array.length == 1) return new PowiainaNum(Math.log10(this.array[0].repeat));
|
|
409
412
|
var x = this.clone();
|
|
410
|
-
x.
|
|
413
|
+
x.array[1].repeat = x.array[1].repeat - 1;
|
|
411
414
|
x.normalize();
|
|
412
415
|
return x;
|
|
413
416
|
}
|
|
@@ -625,6 +628,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
625
628
|
r.sign = this.sign;
|
|
626
629
|
return r;
|
|
627
630
|
}
|
|
631
|
+
}, {
|
|
632
|
+
key: "trunc",
|
|
633
|
+
value: function trunc() {
|
|
634
|
+
var y = this.clone();
|
|
635
|
+
return y.gte(0) ? y.floor() : y.ceil();
|
|
636
|
+
}
|
|
628
637
|
/**
|
|
629
638
|
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
630
639
|
*/
|
|
@@ -957,7 +966,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
957
966
|
value: function toNumber() {
|
|
958
967
|
if (this.sign == -1) return -this.neg().toNumber();
|
|
959
968
|
if (this.small) return 1 / this.rec().toNumber();
|
|
960
|
-
if (this.
|
|
969
|
+
if (this.array.length > 2) return Infinity;
|
|
970
|
+
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));
|
|
961
971
|
return NaN;
|
|
962
972
|
}
|
|
963
973
|
}, {
|
|
@@ -1085,6 +1095,30 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1085
1095
|
var principal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1086
1096
|
return new PowiainaNum(x).lambertw(principal);
|
|
1087
1097
|
}
|
|
1098
|
+
}, {
|
|
1099
|
+
key: "tetrate_10",
|
|
1100
|
+
value: function tetrate_10(other2) {
|
|
1101
|
+
var other = new PowiainaNum(other2);
|
|
1102
|
+
var height_int = other.trunc().toNumber();
|
|
1103
|
+
var height_frac = other.sub(height_int).toNumber();
|
|
1104
|
+
if (other.gt(PowiainaNum.PENTATED_MSI)) return other.clone();else if (other.gt(PowiainaNum.MSI)) {
|
|
1105
|
+
other.setOperator(other.getOperator(2) + 1, 2);
|
|
1106
|
+
} else if (other.lt(-2)) return PowiainaNum.NaN.clone();else if (other.lt(-1)) {
|
|
1107
|
+
return other.add(2).log10();
|
|
1108
|
+
} else if (other.lt(0)) {
|
|
1109
|
+
return other.add(1);
|
|
1110
|
+
} else if (other.lt(1)) {
|
|
1111
|
+
return other.pow10(); // 10^x
|
|
1112
|
+
} else if (height_int == 1) return PowiainaNum.pow(10, PowiainaNum.pow(10, height_frac));else if (height_int == 2) return PowiainaNum.pow(10, PowiainaNum.pow(10, PowiainaNum.pow(10, height_frac)));else {
|
|
1113
|
+
var remain = height_int - 2;
|
|
1114
|
+
var a = PowiainaNum.pow(10, PowiainaNum.pow(10, PowiainaNum.pow(10, height_frac)));
|
|
1115
|
+
a.setOperator(a.getOperator(1) + remain, 1);
|
|
1116
|
+
return a;
|
|
1117
|
+
}
|
|
1118
|
+
// 1--2, 10-<1e10, 10^10^0->1
|
|
1119
|
+
// 2--3, 1e10-<e1e10, 10^10^10^0->1
|
|
1120
|
+
return PowiainaNum.NaN.clone();
|
|
1121
|
+
}
|
|
1088
1122
|
}, {
|
|
1089
1123
|
key: "isNaN",
|
|
1090
1124
|
value: function isNaN(x) {
|
|
@@ -1095,7 +1129,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1095
1129
|
value: function fromNumber(x) {
|
|
1096
1130
|
var obj = new PowiainaNum(); // NaN
|
|
1097
1131
|
if (x < 0) obj.sign = -1; // negative
|
|
1098
|
-
else if (x == 0)
|
|
1132
|
+
else if (x == 0) {
|
|
1133
|
+
obj.sign = 0;
|
|
1134
|
+
obj.small = true;
|
|
1135
|
+
obj.array = [newOperator(Infinity, 0)];
|
|
1136
|
+
return obj;
|
|
1137
|
+
} else if (x > 0) obj.sign = 1;
|
|
1099
1138
|
var y = Math.abs(x);
|
|
1100
1139
|
if (y >= MSI_REC && y < 1) {
|
|
1101
1140
|
obj.small = true;
|
|
@@ -1115,9 +1154,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1115
1154
|
key: "fromString",
|
|
1116
1155
|
value: function fromString(input) {
|
|
1117
1156
|
var _a, _b, _c, _d, _e, _f;
|
|
1118
|
-
if (!isPowiainaNum.test(input)) {
|
|
1119
|
-
throw powiainaNumError + "malformed input: " + input;
|
|
1120
|
-
}
|
|
1121
1157
|
var x = new PowiainaNum();
|
|
1122
1158
|
// Judge the string was a number
|
|
1123
1159
|
// @ts-ignore
|
|
@@ -1128,6 +1164,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1128
1164
|
return x;
|
|
1129
1165
|
}
|
|
1130
1166
|
}
|
|
1167
|
+
if (!isPowiainaNum.test(input)) {
|
|
1168
|
+
throw powiainaNumError + "malformed input: " + input;
|
|
1169
|
+
}
|
|
1131
1170
|
var negateIt = false;
|
|
1132
1171
|
var recipIt = false;
|
|
1133
1172
|
if (input[0] == "-" || input[0] == "+") {
|
|
@@ -1348,6 +1387,43 @@ PowiainaNum.E_MSI_REC = new PowiainaNum({
|
|
|
1348
1387
|
layer: 0,
|
|
1349
1388
|
sign: 1
|
|
1350
1389
|
});
|
|
1390
|
+
PowiainaNum.TETRATED_MSI = new PowiainaNum({
|
|
1391
|
+
array: [{
|
|
1392
|
+
arrow: 0,
|
|
1393
|
+
expans: 1,
|
|
1394
|
+
megota: 1,
|
|
1395
|
+
repeat: MSI
|
|
1396
|
+
}, {
|
|
1397
|
+
arrow: 1,
|
|
1398
|
+
expans: 1,
|
|
1399
|
+
megota: 1,
|
|
1400
|
+
repeat: MSI
|
|
1401
|
+
}],
|
|
1402
|
+
small: false,
|
|
1403
|
+
layer: 0,
|
|
1404
|
+
sign: 1
|
|
1405
|
+
});
|
|
1406
|
+
PowiainaNum.PENTATED_MSI = new PowiainaNum({
|
|
1407
|
+
array: [{
|
|
1408
|
+
arrow: 0,
|
|
1409
|
+
expans: 1,
|
|
1410
|
+
megota: 1,
|
|
1411
|
+
repeat: MSI
|
|
1412
|
+
}, {
|
|
1413
|
+
arrow: 1,
|
|
1414
|
+
expans: 1,
|
|
1415
|
+
megota: 1,
|
|
1416
|
+
repeat: MSI
|
|
1417
|
+
}, {
|
|
1418
|
+
arrow: 2,
|
|
1419
|
+
expans: 1,
|
|
1420
|
+
megota: 1,
|
|
1421
|
+
repeat: MSI
|
|
1422
|
+
}],
|
|
1423
|
+
small: false,
|
|
1424
|
+
layer: 0,
|
|
1425
|
+
sign: 1
|
|
1426
|
+
});
|
|
1351
1427
|
PowiainaNum.TRITRI = new PowiainaNum({
|
|
1352
1428
|
small: false,
|
|
1353
1429
|
layer: 0,
|
package/dist/PowiainaNum.js
CHANGED
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
if (l > MSI_LOG10 || l < -MSI_LOG10) {
|
|
281
281
|
r.array = [newOperator(l, 0), newOperator(1, 1)];
|
|
282
282
|
} else {
|
|
283
|
-
r.array = [newOperator(Math.pow(10, l), 0)];
|
|
283
|
+
r.array = [newOperator(Math.pow(10, Math.abs(l)), 0)];
|
|
284
284
|
}
|
|
285
285
|
r.small = l < 0 ? true : false;
|
|
286
286
|
r.sign *= mult;
|
|
@@ -337,6 +337,9 @@
|
|
|
337
337
|
r.sign *= -1;
|
|
338
338
|
return r.pow10().rec();
|
|
339
339
|
}
|
|
340
|
+
if (r.lte(308.25471555991675)) {
|
|
341
|
+
return PowiainaNum.fromNumber(Math.pow(10, r.toNumber()));
|
|
342
|
+
}
|
|
340
343
|
if (r.small) {
|
|
341
344
|
if (r.lt(PowiainaNum.MSI_REC)) return PowiainaNum.ONE;
|
|
342
345
|
return new PowiainaNum(Math.pow(10, Math.pow(r.array[0].repeat, -1)));
|
|
@@ -363,9 +366,9 @@
|
|
|
363
366
|
return r;
|
|
364
367
|
}
|
|
365
368
|
var a = this.toNumber();
|
|
366
|
-
var b =
|
|
369
|
+
var b = other.toNumber();
|
|
367
370
|
var t = Math.pow(a, b);
|
|
368
|
-
if (
|
|
371
|
+
if (isFinite(t)) {
|
|
369
372
|
// optimize?
|
|
370
373
|
return PowiainaNum.fromNumber(t);
|
|
371
374
|
}
|
|
@@ -411,9 +414,9 @@
|
|
|
411
414
|
_x.small = !_x.small;
|
|
412
415
|
return _x.log10().neg();
|
|
413
416
|
}
|
|
414
|
-
if (this.
|
|
417
|
+
if (this.array.length == 1) return new PowiainaNum(Math.log10(this.array[0].repeat));
|
|
415
418
|
var x = this.clone();
|
|
416
|
-
x.
|
|
419
|
+
x.array[1].repeat = x.array[1].repeat - 1;
|
|
417
420
|
x.normalize();
|
|
418
421
|
return x;
|
|
419
422
|
}
|
|
@@ -631,6 +634,12 @@
|
|
|
631
634
|
r.sign = this.sign;
|
|
632
635
|
return r;
|
|
633
636
|
}
|
|
637
|
+
}, {
|
|
638
|
+
key: "trunc",
|
|
639
|
+
value: function trunc() {
|
|
640
|
+
var y = this.clone();
|
|
641
|
+
return y.gte(0) ? y.floor() : y.ceil();
|
|
642
|
+
}
|
|
634
643
|
/**
|
|
635
644
|
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
636
645
|
*/
|
|
@@ -963,7 +972,8 @@
|
|
|
963
972
|
value: function toNumber() {
|
|
964
973
|
if (this.sign == -1) return -this.neg().toNumber();
|
|
965
974
|
if (this.small) return 1 / this.rec().toNumber();
|
|
966
|
-
if (this.
|
|
975
|
+
if (this.array.length > 2) return Infinity;
|
|
976
|
+
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));
|
|
967
977
|
return NaN;
|
|
968
978
|
}
|
|
969
979
|
}, {
|
|
@@ -1091,6 +1101,30 @@
|
|
|
1091
1101
|
var principal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1092
1102
|
return new PowiainaNum(x).lambertw(principal);
|
|
1093
1103
|
}
|
|
1104
|
+
}, {
|
|
1105
|
+
key: "tetrate_10",
|
|
1106
|
+
value: function tetrate_10(other2) {
|
|
1107
|
+
var other = new PowiainaNum(other2);
|
|
1108
|
+
var height_int = other.trunc().toNumber();
|
|
1109
|
+
var height_frac = other.sub(height_int).toNumber();
|
|
1110
|
+
if (other.gt(PowiainaNum.PENTATED_MSI)) return other.clone();else if (other.gt(PowiainaNum.MSI)) {
|
|
1111
|
+
other.setOperator(other.getOperator(2) + 1, 2);
|
|
1112
|
+
} else if (other.lt(-2)) return PowiainaNum.NaN.clone();else if (other.lt(-1)) {
|
|
1113
|
+
return other.add(2).log10();
|
|
1114
|
+
} else if (other.lt(0)) {
|
|
1115
|
+
return other.add(1);
|
|
1116
|
+
} else if (other.lt(1)) {
|
|
1117
|
+
return other.pow10(); // 10^x
|
|
1118
|
+
} else if (height_int == 1) return PowiainaNum.pow(10, PowiainaNum.pow(10, height_frac));else if (height_int == 2) return PowiainaNum.pow(10, PowiainaNum.pow(10, PowiainaNum.pow(10, height_frac)));else {
|
|
1119
|
+
var remain = height_int - 2;
|
|
1120
|
+
var a = PowiainaNum.pow(10, PowiainaNum.pow(10, PowiainaNum.pow(10, height_frac)));
|
|
1121
|
+
a.setOperator(a.getOperator(1) + remain, 1);
|
|
1122
|
+
return a;
|
|
1123
|
+
}
|
|
1124
|
+
// 1--2, 10-<1e10, 10^10^0->1
|
|
1125
|
+
// 2--3, 1e10-<e1e10, 10^10^10^0->1
|
|
1126
|
+
return PowiainaNum.NaN.clone();
|
|
1127
|
+
}
|
|
1094
1128
|
}, {
|
|
1095
1129
|
key: "isNaN",
|
|
1096
1130
|
value: function isNaN(x) {
|
|
@@ -1101,7 +1135,12 @@
|
|
|
1101
1135
|
value: function fromNumber(x) {
|
|
1102
1136
|
var obj = new PowiainaNum(); // NaN
|
|
1103
1137
|
if (x < 0) obj.sign = -1; // negative
|
|
1104
|
-
else if (x == 0)
|
|
1138
|
+
else if (x == 0) {
|
|
1139
|
+
obj.sign = 0;
|
|
1140
|
+
obj.small = true;
|
|
1141
|
+
obj.array = [newOperator(Infinity, 0)];
|
|
1142
|
+
return obj;
|
|
1143
|
+
} else if (x > 0) obj.sign = 1;
|
|
1105
1144
|
var y = Math.abs(x);
|
|
1106
1145
|
if (y >= MSI_REC && y < 1) {
|
|
1107
1146
|
obj.small = true;
|
|
@@ -1121,9 +1160,6 @@
|
|
|
1121
1160
|
key: "fromString",
|
|
1122
1161
|
value: function fromString(input) {
|
|
1123
1162
|
var _a, _b, _c, _d, _e, _f;
|
|
1124
|
-
if (!isPowiainaNum.test(input)) {
|
|
1125
|
-
throw powiainaNumError + "malformed input: " + input;
|
|
1126
|
-
}
|
|
1127
1163
|
var x = new PowiainaNum();
|
|
1128
1164
|
// Judge the string was a number
|
|
1129
1165
|
// @ts-ignore
|
|
@@ -1134,6 +1170,9 @@
|
|
|
1134
1170
|
return x;
|
|
1135
1171
|
}
|
|
1136
1172
|
}
|
|
1173
|
+
if (!isPowiainaNum.test(input)) {
|
|
1174
|
+
throw powiainaNumError + "malformed input: " + input;
|
|
1175
|
+
}
|
|
1137
1176
|
var negateIt = false;
|
|
1138
1177
|
var recipIt = false;
|
|
1139
1178
|
if (input[0] == "-" || input[0] == "+") {
|
|
@@ -1354,6 +1393,43 @@
|
|
|
1354
1393
|
layer: 0,
|
|
1355
1394
|
sign: 1
|
|
1356
1395
|
});
|
|
1396
|
+
PowiainaNum.TETRATED_MSI = new PowiainaNum({
|
|
1397
|
+
array: [{
|
|
1398
|
+
arrow: 0,
|
|
1399
|
+
expans: 1,
|
|
1400
|
+
megota: 1,
|
|
1401
|
+
repeat: MSI
|
|
1402
|
+
}, {
|
|
1403
|
+
arrow: 1,
|
|
1404
|
+
expans: 1,
|
|
1405
|
+
megota: 1,
|
|
1406
|
+
repeat: MSI
|
|
1407
|
+
}],
|
|
1408
|
+
small: false,
|
|
1409
|
+
layer: 0,
|
|
1410
|
+
sign: 1
|
|
1411
|
+
});
|
|
1412
|
+
PowiainaNum.PENTATED_MSI = new PowiainaNum({
|
|
1413
|
+
array: [{
|
|
1414
|
+
arrow: 0,
|
|
1415
|
+
expans: 1,
|
|
1416
|
+
megota: 1,
|
|
1417
|
+
repeat: MSI
|
|
1418
|
+
}, {
|
|
1419
|
+
arrow: 1,
|
|
1420
|
+
expans: 1,
|
|
1421
|
+
megota: 1,
|
|
1422
|
+
repeat: MSI
|
|
1423
|
+
}, {
|
|
1424
|
+
arrow: 2,
|
|
1425
|
+
expans: 1,
|
|
1426
|
+
megota: 1,
|
|
1427
|
+
repeat: MSI
|
|
1428
|
+
}],
|
|
1429
|
+
small: false,
|
|
1430
|
+
layer: 0,
|
|
1431
|
+
sign: 1
|
|
1432
|
+
});
|
|
1357
1433
|
PowiainaNum.TRITRI = new PowiainaNum({
|
|
1358
1434
|
small: false,
|
|
1359
1435
|
layer: 0,
|
package/dist/PowiainaNum.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).PowiainaNum=e()}(this,(function(){"use strict";function r(r,a){for(var t=0;t<a.length;t++){var n=a[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,e(n.key),n)}}function e(r){var e=function(r,e){if("object"!=typeof r||!r)return r;var a=r[Symbol.toPrimitive];if(void 0!==a){var t=a.call(r,e||"default");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==typeof e?e:e+""}function a(r){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var t=9007199254740991,n=15.954589770191003,i=/^[-\+]*(Infinity|NaN|(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})|\(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})\)\^[1-9]\d* )*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/;function o(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{repeat:r,arrow:e,expans:a,megota:t,valuereplaced:e==1/0?0:a==1/0?1:-1}}function s(){for(var r=arguments.length,e=new Array(r),a=0;a<r;a++)e[a]=arguments[a];for(var t=0;t<Math.min(e[0].length,e[1].length);t++){var n=e[0][t],i=e[1][t];if(n<i)return-1;if(n>i)return 1}return 0}function l(r){return Math.log10(Number(r.substring(0,17)))+(r.length-17)}var u=.5671432904097838;function h(r){var e,a,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!Number.isFinite(r))return r;if(n){if(0===r)return r;if(1===r)return u;e=r<10?0:Math.log(r)-Math.log(Math.log(r))}else{if(0===r)return-1/0;e=r<=-.1?-2:Math.log(-r)-Math.log(-Math.log(-r))}for(var i=0;i<100;++i){if(a=(r*Math.exp(-e)+e*e)/(e+1),Math.abs(a-e)<t*Math.abs(a))return a;e=a}throw Error("Iteration failed to converge: ".concat(r.toString()))}function g(r){var e,a,t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(r.isInfinite())return r;if(o){if(r.eq(p.ZERO))return p.ZERO.clone();if(r.eq(p.ONE))return p.fromNumber(u);e=r.log()}else{if(r.eq(p.ZERO))return p.NEGATIVE_INFINITY.clone();e=r.neg().log()}for(var s=0;s<100;++s){if(a=e.neg().exp(),t=e.sub(r.mul(a)),(n=e.sub(t.div(e.add(1).sub(e.add(2).mul(t).div(e.mul(2).add(2)))))).sub(e).abs().lt(n.abs().mul(i)))return n;e=n}throw Error("Iteration failed to converge: ".concat(r.toString()))}var y,p=function(){function e(r){if(function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.array=[{arrow:0,expans:1,megota:1,repeat:NaN}],this.small=!1,this.sign=0,this.layer=0,void 0===r);else if("number"==typeof r){var t=e.fromNumber(r);this.resetFromObject(t)}else if("object"==a(r)){var n=e.fromObject(r);this.resetFromObject(n)}else if("string"==typeof r){var i=e.fromString(r);this.resetFromObject(i)}}return function(e,a,t){return a&&r(e.prototype,a),t&&r(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}(e,[{key:"add",value:function(r){var a,t,i,s,l,u,h=this.clone(),g=new e(r);if(h.eq(e.POSITIVE_INFINITY)&&g.eq(e.NEGATIVE_INFINITY)||h.eq(e.NEGATIVE_INFINITY)&&g.eq(e.POSITIVE_INFINITY))return e.NaN.clone();if(!h.isFinite())return h.clone();if(!g.isFinite())return g.clone();if(h.isZero())return g.clone();if(g.isZero())return h.clone();if(h.sign==-g.sign&&function(){var r=h.abs(),e=g.abs();return r.eq(e)}())return e.ZERO.clone();if(h.abs().lt(e.E_MSI_REC)||h.abs().gt(e.E_MSI)||g.abs().lt(e.E_MSI_REC)||g.abs().gt(e.E_MSI))return h.maxabs(g);if(-1==h.sign)return h.neg().add(g.neg()).neg();h.cmpabs(g)>0?(l=h,u=g):(u=h,l=g);var y=1;if(!(l.small||u.small||(null===(a=l.array[1])||void 0===a?void 0:a.repeat)||(null===(t=u.array[1])||void 0===t?void 0:t.repeat)||l.sign!=u.sign))return new e((l.array[0].repeat+u.array[0].repeat)*l.sign);var p=(l.small?-1:1)*((null===(i=l.array[1])||void 0===i?void 0:i.repeat)?l.array[0].repeat:Math.log10(l.array[0].repeat)),f=(u.small?-1:1)*((null===(s=u.array[1])||void 0===s?void 0:s.repeat)?u.array[0].repeat:Math.log10(u.array[0].repeat));if(p-f>n)return l;var c,v,m=-Math.floor(p),N=0;if((v=l.sign*Math.pow(10,p+m)+u.sign*Math.pow(10,f+m))>0&&(N=Math.log10(v)-m),v<0&&(N=Math.log10(-v)-m,y*=-1),0==v)throw Error("Encounter a calculate error");return(c=new e).sign=1,c.array=N>n||N<-n?[o(N,0),o(1,1)]:[o(Math.pow(10,N),0)],c.small=N<0,c.sign*=y,c}},{key:"sub",value:function(r){return this.add(new e(r).neg())}},{key:"mul",value:function(r){var a,t=this.clone(),n=new e(r);return t.eq(e.POSITIVE_INFINITY)&&n.eq(e.NEGATIVE_INFINITY)||n.eq(e.POSITIVE_INFINITY)&&t.eq(e.NEGATIVE_INFINITY)?e.NEGATIVE_INFINITY.clone():t.isInfinite()&&n.eq(e.ZERO)&&n.isInfinite()&&t.eq(e.ZERO)?e.NaN.clone():t.eq(e.NEGATIVE_INFINITY)&&n.eq(e.NEGATIVE_INFINITY)?e.POSITIVE_INFINITY.clone():t.isFinite()?n.isFinite()?t.isZero()||n.isZero()?e.ZERO.clone():((a=t.abs().log10().add(n.abs().log10()).pow10()).sign=t.sign*n.sign,a):n.clone():t.clone()}},{key:"div",value:function(r){var a=new e(r).rec();return this.mul(a)}},{key:"pow10",value:function(){var r,a,t=this.clone();return this.isFinite()?t.isneg()?(t.sign*=-1,t.pow10().rec()):t.small?t.lt(e.MSI_REC)?e.ONE:new e(Math.pow(10,Math.pow(t.array[0].repeat,-1))):(t.setOperator((null!==(a=null===(r=t.array[1])||void 0===r?void 0:r.repeat)&&void 0!==a?a:0)+1,1),t.normalize(),t):this.clone()}},{key:"pow",value:function(r){var a=new e(r);if(!a.isFinite())return a.clone();if(!this.isFinite())return this.clone();if(this.eq(10))return a.pow10();if(this.isneg()){if(!a.isInt())return e.NaN.clone();var t=this.abs().pow(a);return t.sign=function(){var r=a.mod(2).round();return r.eq(0)||r.eq(2)?1:-1}(),t}var n=this.toNumber(),i=this.toNumber(),o=Math.pow(n,i);return isFinite(o)?this.log10().mul(a).pow10():e.fromNumber(o)}},{key:"pow_base",value:function(r){return new e(r).pow(this)}},{key:"root",value:function(r){var a=new e(r);return this.pow(a.rec())}},{key:"sqrt",value:function(){return this.pow(.5)}},{key:"cbrt",value:function(){return this.root(3)}},{key:"abs",value:function(){var r=this.clone();return r.sign<0&&(r.sign*=-1),r}},{key:"log10",value:function(){if(this.isneg())return e.NaN.clone();if(this.isZero())return e.NEGATIVE_INFINITY.clone();if(this.small){var r=this.clone();return r.small=!r.small,r.log10().neg()}if(0==this.getOperator(1))return new e(Math.log10(this.getOperator(0)));var a=this.clone();return a.setOperator(a.getOperator(1)-1,1),a.normalize(),a}},{key:"log",value:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.E,a=new e(r);return this.log10().div(a.log10())}},{key:"exp",value:function(){return this.pow_base(Math.E)}},{key:"mod",value:function(r){var a=new e(r),t=this.div(a);return t.sub(t.floor()).mul(a)}},{key:"factorial",value:function(){return this.abs().lt(t)?this.add(1).gamma():this.abs().lt(e.E_MSI)?e.exp(this.mul(this.log10().sub(1))):e.exp(this)}},{key:"gamma",value:function(){if(this.small)return this.rec();if(this.lte(t)){if(this.lt(24))return e.fromNumber(function(r){if(!isFinite(r))return r;if(r<-50)return r===Math.trunc(r)?Number.NEGATIVE_INFINITY:0;for(var e=1;r<10;)e*=r,++r;var a=.9189385332046727;a+=((r-=1)+.5)*Math.log(r),a-=r;var t=r*r,n=r;return a+=1/(12*n),a-=1/(360*(n*=t)),a+=1/(1260*(n*=t)),a-=1/(1680*(n*=t)),a+=1/(1188*(n*=t)),a-=691/(360360*(n*=t)),a+=7/(1092*(n*=t)),a-=3617/(122400*(n*=t)),Math.exp(a)/e}(this.sign*this.getOperator(0)));var r=this.getOperator(0)-1,a=.9189385332046727;a+=(r+.5)*Math.log(r);var n=r*r,i=r,o=12*i,s=1/o,l=(a-=r)+s;if(l===a)return e.exp(a);if((l=(a=l)-(s=1/(o=360*(i*=n))))===a)return e.exp(a);a=l;var u=1/(o=1260*(i*=n));return a+=u,a-=u=1/(o=1680*(i*=n)),e.exp(a)}return this.gt(t)?e.exp(this.mul(this.log().sub(1))):e.exp(this)}},{key:"lambertw",value:function(){var r=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.lt(-.3678794411710499)?e.NaN.clone():r?this.abs().lt("1e-300")?new e(this):this.small?e.fromNumber(h(this.toNumber())):0===this.layer?e.fromNumber(h(this.sign*this.getOperator(0))):this.lt("eee15")?g(this):this.log():1===this.sign?e.NaN.clone():0===this.layer?e.fromNumber(h(this.sign*this.array[0].repeat,1e-10,!1)):1==this.layer?g(this,1e-10,!1):this.neg().rec().lambertw().neg()}},{key:"max",value:function(r){var a=new e(r);return this.lt(a)?a.clone():this.clone()}},{key:"min",value:function(r){var a=new e(r);return this.gte(a)?a.clone():this.clone()}},{key:"maxabs",value:function(r){var a=new e(r).abs();return this.abs().lt(a)?a.clone():this.clone()}},{key:"minabs",value:function(r){var a=new e(r).abs();return this.abs().gt(a)?a.clone():this.clone()}},{key:"cmpabs",value:function(r){var a=new e(r).abs();return this.abs().cmp(a)}},{key:"neg",value:function(){var r=this.clone();return r.sign*=-1,r.normalize(),r}},{key:"rec",value:function(){var r=this.clone();return r.small=!r.small,r}},{key:"floor",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?e.ZERO.clone():e.ONE.neg().clone();var r=this.abs();return r.array[0].repeat=Math[1==this.sign?"floor":"ceil"](r.getOperator(0)),r}},{key:"ceil",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?e.ONE.clone():e.ZERO.clone();var r=this.abs();return r.array[0].repeat=Math[1==this.sign?"ceil":"floor"](r.getOperator(0)),r.sign=this.sign,r}},{key:"round",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?this.rec().lte(2)?e.ONE.clone():e.ZERO.clone():this.abs().rec().lte(2)?e.ZERO.clone():e.ONE.neg().clone();var r=this.abs();return r.array[0].repeat=Math.round(r.array[0].repeat),r.sign=this.sign,r}},{key:"compare",value:function(r){var a=new e(r);if(this.isNaN()||a.isNaN())return 2;if(this.sign<a.sign)return-1;if(this.sign>a.sign)return 1;var t=-1==this.sign&&-1==a.sign;if(this.small&&!a.small)return-1*(t?-1:1);if(a.small&&!this.small)return 1*(t?-1:1);var n=1;this.small&&a.small&&(n*=-1),t&&(n*=-1);for(var i=0,o=0;this.array.length-1-o>=0&&a.array.length-1-o>=0;o++){var l=this.array[this.array.length-1-o],u=a.array[a.array.length-1-o],h=s([l.megota,l.expans,l.arrow,l.repeat],[u.megota,u.expans,u.arrow,u.repeat]);if(1==h){i=1;break}if(-1==h){i=-1;break}}return i*n+1-1}},{key:"cmp",value:function(r){return this.compare(r)}},{key:"eq",value:function(r){return 0===this.cmp(r)}},{key:"neq",value:function(r){return 0!==this.cmp(r)}},{key:"lt",value:function(r){return-1===this.cmp(r)}},{key:"lte",value:function(r){return this.cmp(r)<=0}},{key:"gt",value:function(r){return 1==this.cmp(r)}},{key:"gte",value:function(r){var e=this.cmp(r);return 0==e||1==e}},{key:"isNaN",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return isNaN(this.getOperator(0))}))},{key:"isZero",value:function(){return Boolean(this.small&&!isFinite(this.getOperator(0)))}},{key:"isFinite",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return Boolean(this.small||isFinite(this.getOperator(0)))&&!this.isNaN()}))},{key:"isInfinite",value:function(){return Boolean(!this.small&&!isFinite(this.getOperator(0)))||this.isNaN()}},{key:"isInt",value:function(){return!!this.isZero()||(!(this.small||!Number.isInteger(this.getOperator(0)))||!!this.abs().gte(t/2))}},{key:"ispos",value:function(){return this.sign>0}},{key:"isneg",value:function(){return this.sign<0}},{key:"normalize",value:function(){for(var r=!0,a=this,i=0;i<this.array.length;i++)if(this.array[i].repeat==1/0)return this.array=[{arrow:0,expans:1,megota:1,repeat:1/0}],this.layer=0,this;for(var l=1;l<a.array.length;++l){var u=a.array[l];if(null!==u.arrow&&void 0!==u.arrow||(u.arrow=0),null!==u.expans&&void 0!==u.expans||(u.expans=1),null!==u.megota&&void 0!==u.megota||(u.megota=1),isNaN(u.arrow)||isNaN(u.repeat)||isNaN(u.expans)||isNaN(u.megota))return a.array=[o(NaN,0,1,1)],a;if(!isFinite(u.repeat)||!isFinite(u.megota))return a.array=[o(1/0,0,1,1)],a;Number.isInteger(u.arrow)||(u.arrow=Math.floor(u.arrow)),Number.isInteger(u.repeat)||(u.repeat=Math.floor(u.repeat)),Number.isInteger(u.expans)||(u.expans=Math.floor(u.expans)),Number.isInteger(u.megota)||(u.megota=Math.floor(u.megota))}do{for(r=!1,this.array.sort((function(r,e){return s([r.megota,r.expans,r.arrow],[e.megota,e.expans,e.arrow])})),l=1;l<a.array.length;++l)0===a.array[l].arrow||0!==a.array[l].repeat&&null!==a.array[l].repeat&&void 0!==a.array[l].repeat?0==a.array[l].arrow&&a.array[l].expans>=2&&(a.array[l].arrow=1/0,a.array[l].valuereplaced=0,a.array[l].expans=a.array[l].expans-1):(a.array.splice(l,1),--l);for(var h=1;h<this.array.length;h++)0==this.array[h].repeat&&(this.array.splice(h,1),h--);for(a.array.length||(a.small=!a.small,a.array=[o(1/0)]),a.array.length>e.maxOps&&a.array.splice(1,a.array.length-e.maxOps),this.getOperator(1)>=1&&this.getOperator(0)<n&&(this.setOperator(this.getOperator(1)-1,1),this.setOperator(Math.pow(10,this.getOperator(0)),0),r=!0),this.getOperator(0)>t&&(this.setOperator(this.getOperator(1)+1,1),this.setOperator(Math.log10(this.getOperator(0)),0),r=!0),1==this.array.length&&this.array[0].repeat<1&&(this.array[0].repeat=1/this.array[0].repeat,this.small=!this.small,r=!0);a.array.length>=2&&1==a.array[0].repeat&&a.array[1].repeat;)a.array[1].repeat>1?a.array[1].repeat--:a.array.splice(1,1),a.array[0].repeat=10,r=!0;for(a.array.length>=2&&a.array[0].repeat<t&&a.array[1].arrow>=2&&1==a.array[1].repeat&&(a.array.splice(1,1,o(a.array[0].repeat,a.array[1].arrow-1,a.array[1].expans,a.array[1].megota)),a.array[0].repeat=10,r=!0),l=1;l<a.array.length-1;++l)a.array[l].arrow==a.array[l+1].arrow&&a.array[l].expans==a.array[l+1].expans&&a.array[l].megota==a.array[l+1].megota&&(a.array[l].repeat+=a.array[l+1].repeat,a.array.splice(l+1,1),--l,r=!0)}while(r);return this}},{key:"getOperatorIndex",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(1==this.array.length&&0==r)return 0;if(1==this.array.length&&1==r)return.5;if(2==this.array.length&&1==r)return 1;if(2==this.array.length&&0==r)return 0;for(var t=0;t<this.array.length;t++){var n=s([this.array[t].megota,this.array[t].expans,this.array[t].arrow],[a,e,r]);if(0==n)return t;if(1==n)return t-.5}return this.array.length-.5}},{key:"getOperator",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,t=this.getOperatorIndex(r,e,a);return this.array[t]?this.array[t].repeat:0}},{key:"setOperator",value:function(r,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=this.getOperatorIndex(e,a,t);return this.array[n]?(this.array[n].repeat=r,!1):(this.array.splice(Math.ceil(n),0,{arrow:e,expans:a,megota:t,valuereplaced:a===1/0?1:e==1/0?0:-1,repeat:r}),!0)}},{key:"clone",value:function(){var r=new e;return r.resetFromObject(this),r}},{key:"resetFromObject",value:function(r){this.array=[];for(var e=0;e<r.array.length;e++)this.array[e]={arrow:r.array[e].arrow,expans:r.array[e].expans,megota:r.array[e].megota,repeat:r.array[e].repeat,valuereplaced:r.array[e].valuereplaced};return this.small=r.small,this.sign=r.sign,this.layer=r.layer,this}},{key:"toNumber",value:function(){return-1==this.sign?-this.neg().toNumber():this.small?1/this.rec().toNumber():0==this.getOperator(1)?this.getOperator(0):1==this.getOperator(1)?Math.pow(10,this.getOperator(0)):NaN}},{key:"toString",value:function(){if(this.isNaN())return"NaN";if(-1==this.sign)return"-".concat(this.neg().toString());if(this.small)return this.eq(e.ZERO)?"0":"/".concat(this.rec().toString());if(this.isInfinite())return"Infinity";for(var r="",a=this.array.length-1;a>=0;a--){var t=this.array[a],n="10{".concat(t.arrow===1/0?"!":t.arrow).concat(t.expans>1||t.megota>1?",".concat(t.expans===1/0?"!":t.expans):"").concat(t.megota>1?",".concat(t.megota):"","}");n=1==t.arrow&&1==t.expans&&1==t.megota&&t.repeat<5?"e".repeat(t.repeat):0==t.arrow&&1==t.expans&&1==t.megota?t.repeat.toString():t.repeat>1?"(".concat(n,")^").concat(t.repeat," "):"".concat(n," "),r+="".concat(n)}return r}},{key:"arr01",get:function(){for(var r=[0],e=0;e<this.array.length;e++)0==e?r[0]=this.array[e].repeat:(r[e]=[0,0,0,0],r[e][0]=this.array[e].arrow==1/0?"x":this.array[e].arrow,r[e][1]=this.array[e].repeat,r[e][2]=this.array[e].expans==1/0?"x":this.array[e].expans,r[e][3]=this.array[e].megota);return r}}],[{key:"add",value:function(r,a){return new e(r).add(a)}},{key:"sub",value:function(r,a){return new e(r).sub(a)}},{key:"mul",value:function(r,a){return new e(r).mul(a)}},{key:"div",value:function(r,a){return new e(r).div(a)}},{key:"pow",value:function(r,a){return new e(r).pow(a)}},{key:"root",value:function(r,a){return new e(r).root(a)}},{key:"sqrt",value:function(r){return new e(r).sqrt()}},{key:"cbrt",value:function(r){return new e(r).cbrt()}},{key:"log10",value:function(r){return new e(r).log10()}},{key:"log",value:function(r){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new e(r).log(a)}},{key:"exp",value:function(r){return new e(r).pow_base(Math.E)}},{key:"factorial",value:function(r){return new e(r).factorial()}},{key:"gamma",value:function(r){return new e(r).gamma()}},{key:"lambertw",value:function(r){var a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new e(r).lambertw(a)}},{key:"isNaN",value:function(r){return new e(r).isNaN()}},{key:"fromNumber",value:function(r){var a=new e;r<0?a.sign=-1:0==r?a.sign=0:r>0&&(a.sign=1);var n=Math.abs(r);return n>=11102230246251568e-32&&n<1?(a.small=!0,a.array=[o(1/n,0)]):n<11102230246251568e-32?(a.small=!0,a.array=[o(-Math.log10(n),0),o(1,1)]):n<=t?a.array=[o(n,0)]:(a.setOperator(Math.log10(n),0),a.array=[o(Math.log10(n),0),o(1,1)]),a}},{key:"fromString",value:function(r){var a,s,u,h,g,y;if(!i.test(r))throw"[PowiainaNum 0.2 error]malformed input: "+r;var p=new e;if(!isNaN(Number(r))&&isFinite(Number(r)))return p.resetFromObject(e.fromNumber(Number(r))),p;var f=!1,c=!1;if("-"==r[0]||"+"==r[0]){var v=r.search(/[^-\+]/);f=(null!==(s=null===(a=r.substring(0,v).match(/-/g))||void 0===a?void 0:a.length)&&void 0!==s?s:0)%2==1,r=r.substring(v)}if("/"==r[0]){v=r.search(/[^\/]/);c=(null!==(h=null===(u=r.substring(0,v).match(/\//g))||void 0===u?void 0:u.length)&&void 0!==h?h:0)%2==1,r=r.substring(v)}if("NaN"==r)p.array=[o(NaN)];else if("Infinity"==r)p.array=[o(1/0)];else{var m,N,w,b;for(p.sign=1,p.array=[o(0)];r&&/^(\(?10[\^\{])/.test(r);){var d,I,O;if("("==r[0]&&(r=r.substring(1)),"^"==r[2])d=m=r.substring(2).search(/[^\^]/),N=m+2;else{m=r.indexOf("}");var E=r.substring(3,m).split(",");d=Number("!"==E[0]?1/0:E[0]),I=Number(null!==(g="!"==E[1]?1/0:E[1])&&void 0!==g?g:1),O=Number(null!==(y=E[2])&&void 0!==y?y:1),N=m+1}")"==(r=r.substring(N))[0]?(m=r.indexOf(" "),w=Number(r.substring(2,m)),r=r.substring(m+1)):w=1,1==d&&1==I&&1==O?p.array.length>=2&&1==p.array[1].arrow?p.array[1].repeat+=w:p.array.splice(1,0,o(w,1,I,O)):2==d&&1==I&&1==O?(m=p.array.length>=2&&1==p.array[1].arrow?p.array[1].repeat:0,(N=p.array[0].repeat)>=1e10&&++m,N>=10&&++m,p.array[0].repeat=m,p.array.length>=2&&1==p.array[1].arrow&&p.array.splice(1,1),b=p.getOperatorIndex(2),Number.isInteger(b)?p.array[b].repeat+=w:p.array.splice(Math.ceil(b),0,o(w,2,I,O))):isFinite(d)?(m=p.getOperator(d-1),(N=p.getOperator(d-2))>=10&&++m,b=p.getOperatorIndex(d),p.array.splice(1,Math.ceil(b)-1),p.array[0].repeat=m,Number.isInteger(b)?p.array[1].repeat+=w:p.array.splice(1,0,o(w,d,I,O))):p.array.splice(1,0,o(w,d,I,O))}m=r.split(/[Ee]/),N=[p.array[0].repeat,0],w=1;for(var M=m.length-1;M>=0;--M){N[0]<n&&0===N[1]?N[0]=Math.pow(10,w*N[0]):-1==w?(0===N[1]?N[0]=Math.pow(10,w*N[0]):1==N[1]&&N[0]<=Math.log10(Number.MAX_VALUE)?N[0]=Math.pow(10,w*Math.pow(10,N[0])):N[0]=0,N[1]=0):N[1]++;var k=m[M].indexOf("."),x=-1==k?m[M].length:k;0===N[1]?x>=17?(N[0]=Math.log10(N[0])+l(m[M].substring(0,x)),N[1]=1):m[M]&&(N[0]*=Number(m[M])):(b=x>=17?l(m[M].substring(0,x)):m[M]?Math.log10(Number(m[M])):0,1==N[1]?N[0]+=b:2==N[1]&&N[0]<n+Math.log10(b)&&(N[0]+=Math.log10(1+Math.pow(10,Math.log10(b)-N[0])))),N[0]<n&&N[1]?(N[0]=Math.pow(10,N[0]),N[1]--):N[0]>t&&(N[0]=Math.log10(N[0]),N[1]++)}p.array[0].repeat=N[0],N[1]&&(p.array.length>=2&&1==p.array[1].arrow?p.array[1].repeat+=N[1]:p.array.splice(1,0,o(N[1],1,1,1)))}return f&&(p.sign*=-1),c&&(p.small=!p.small),p.normalize(),p.normalize(),p}},{key:"fromObject",value:function(r){var a=new e;a.array=[];for(var t=0;t<r.array.length;t++)a.array[t]={arrow:r.array[t].arrow,expans:r.array[t].expans,megota:r.array[t].megota,repeat:r.array[t].repeat,valuereplaced:r.array[t].valuereplaced};return a.small=r.small,a.sign=r.sign,a.layer=r.layer,a}}])}();return p.ZERO=new p({array:[{arrow:0,expans:1,megota:1,repeat:1/0}],small:!0,layer:0,sign:0}),p.ONE=new p({array:[{arrow:0,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),p.MSI=new p(t),p.MSI_REC=((y=new p(t)).small=!0,y),p.E_MSI=new p({array:[{arrow:0,expans:1,megota:1,repeat:t},{arrow:1,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),p.E_MSI_REC=new p({array:[{arrow:0,expans:1,megota:1,repeat:t},{arrow:1,expans:1,megota:1,repeat:1}],small:!0,layer:0,sign:1}),p.TRITRI=new p({small:!1,layer:0,sign:1,array:[o(3638334640023.7783,0,1,1),o(7625587484984,1,1,1)]}),p.GRAHAMS_NUMBER=new p("(10{!})^63 10^^^(10^)^7625597484984 3638334640023.7783"),p.POSITIVE_INFINITY=new p(1/0),p.NEGATIVE_INFINITY=new p(-1/0),p.NaN=new p({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),p.maxOps=100,p}));
|
|
1
|
+
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).PowiainaNum=e()}(this,(function(){"use strict";function r(r,a){for(var t=0;t<a.length;t++){var n=a[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,e(n.key),n)}}function e(r){var e=function(r,e){if("object"!=typeof r||!r)return r;var a=r[Symbol.toPrimitive];if(void 0!==a){var t=a.call(r,e||"default");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==typeof e?e:e+""}function a(r){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var t=9007199254740991,n=15.954589770191003,i=/^[-\+]*(Infinity|NaN|(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})|\(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})\)\^[1-9]\d* )*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/;function o(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{repeat:r,arrow:e,expans:a,megota:t,valuereplaced:e==1/0?0:a==1/0?1:-1}}function s(){for(var r=arguments.length,e=new Array(r),a=0;a<r;a++)e[a]=arguments[a];for(var t=0;t<Math.min(e[0].length,e[1].length);t++){var n=e[0][t],i=e[1][t];if(n<i)return-1;if(n>i)return 1}return 0}function l(r){return Math.log10(Number(r.substring(0,17)))+(r.length-17)}var u=.5671432904097838;function h(r){var e,a,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!Number.isFinite(r))return r;if(n){if(0===r)return r;if(1===r)return u;e=r<10?0:Math.log(r)-Math.log(Math.log(r))}else{if(0===r)return-1/0;e=r<=-.1?-2:Math.log(-r)-Math.log(-Math.log(-r))}for(var i=0;i<100;++i){if(a=(r*Math.exp(-e)+e*e)/(e+1),Math.abs(a-e)<t*Math.abs(a))return a;e=a}throw Error("Iteration failed to converge: ".concat(r.toString()))}function g(r){var e,a,t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(r.isInfinite())return r;if(o){if(r.eq(p.ZERO))return p.ZERO.clone();if(r.eq(p.ONE))return p.fromNumber(u);e=r.log()}else{if(r.eq(p.ZERO))return p.NEGATIVE_INFINITY.clone();e=r.neg().log()}for(var s=0;s<100;++s){if(a=e.neg().exp(),t=e.sub(r.mul(a)),(n=e.sub(t.div(e.add(1).sub(e.add(2).mul(t).div(e.mul(2).add(2)))))).sub(e).abs().lt(n.abs().mul(i)))return n;e=n}throw Error("Iteration failed to converge: ".concat(r.toString()))}var y,p=function(){function e(r){if(function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.array=[{arrow:0,expans:1,megota:1,repeat:NaN}],this.small=!1,this.sign=0,this.layer=0,void 0===r);else if("number"==typeof r){var t=e.fromNumber(r);this.resetFromObject(t)}else if("object"==a(r)){var n=e.fromObject(r);this.resetFromObject(n)}else if("string"==typeof r){var i=e.fromString(r);this.resetFromObject(i)}}return function(e,a,t){return a&&r(e.prototype,a),t&&r(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}(e,[{key:"add",value:function(r){var a,t,i,s,l,u,h=this.clone(),g=new e(r);if(h.eq(e.POSITIVE_INFINITY)&&g.eq(e.NEGATIVE_INFINITY)||h.eq(e.NEGATIVE_INFINITY)&&g.eq(e.POSITIVE_INFINITY))return e.NaN.clone();if(!h.isFinite())return h.clone();if(!g.isFinite())return g.clone();if(h.isZero())return g.clone();if(g.isZero())return h.clone();if(h.sign==-g.sign&&function(){var r=h.abs(),e=g.abs();return r.eq(e)}())return e.ZERO.clone();if(h.abs().lt(e.E_MSI_REC)||h.abs().gt(e.E_MSI)||g.abs().lt(e.E_MSI_REC)||g.abs().gt(e.E_MSI))return h.maxabs(g);if(-1==h.sign)return h.neg().add(g.neg()).neg();h.cmpabs(g)>0?(l=h,u=g):(u=h,l=g);var y=1;if(!(l.small||u.small||(null===(a=l.array[1])||void 0===a?void 0:a.repeat)||(null===(t=u.array[1])||void 0===t?void 0:t.repeat)||l.sign!=u.sign))return new e((l.array[0].repeat+u.array[0].repeat)*l.sign);var p=(l.small?-1:1)*((null===(i=l.array[1])||void 0===i?void 0:i.repeat)?l.array[0].repeat:Math.log10(l.array[0].repeat)),f=(u.small?-1:1)*((null===(s=u.array[1])||void 0===s?void 0:s.repeat)?u.array[0].repeat:Math.log10(u.array[0].repeat));if(p-f>n)return l;var c,m,v=-Math.floor(p),w=0;if((m=l.sign*Math.pow(10,p+v)+u.sign*Math.pow(10,f+v))>0&&(w=Math.log10(m)-v),m<0&&(w=Math.log10(-m)-v,y*=-1),0==m)throw Error("Encounter a calculate error");return(c=new e).sign=1,c.array=w>n||w<-n?[o(w,0),o(1,1)]:[o(Math.pow(10,Math.abs(w)),0)],c.small=w<0,c.sign*=y,c}},{key:"sub",value:function(r){return this.add(new e(r).neg())}},{key:"mul",value:function(r){var a,t=this.clone(),n=new e(r);return t.eq(e.POSITIVE_INFINITY)&&n.eq(e.NEGATIVE_INFINITY)||n.eq(e.POSITIVE_INFINITY)&&t.eq(e.NEGATIVE_INFINITY)?e.NEGATIVE_INFINITY.clone():t.isInfinite()&&n.eq(e.ZERO)&&n.isInfinite()&&t.eq(e.ZERO)?e.NaN.clone():t.eq(e.NEGATIVE_INFINITY)&&n.eq(e.NEGATIVE_INFINITY)?e.POSITIVE_INFINITY.clone():t.isFinite()?n.isFinite()?t.isZero()||n.isZero()?e.ZERO.clone():((a=t.abs().log10().add(n.abs().log10()).pow10()).sign=t.sign*n.sign,a):n.clone():t.clone()}},{key:"div",value:function(r){var a=new e(r).rec();return this.mul(a)}},{key:"pow10",value:function(){var r,a,t=this.clone();return this.isFinite()?t.isneg()?(t.sign*=-1,t.pow10().rec()):t.lte(308.25471555991675)?e.fromNumber(Math.pow(10,t.toNumber())):t.small?t.lt(e.MSI_REC)?e.ONE:new e(Math.pow(10,Math.pow(t.array[0].repeat,-1))):(t.setOperator((null!==(a=null===(r=t.array[1])||void 0===r?void 0:r.repeat)&&void 0!==a?a:0)+1,1),t.normalize(),t):this.clone()}},{key:"pow",value:function(r){var a=new e(r);if(!a.isFinite())return a.clone();if(!this.isFinite())return this.clone();if(this.eq(10))return a.pow10();if(this.isneg()){if(!a.isInt())return e.NaN.clone();var t=this.abs().pow(a);return t.sign=function(){var r=a.mod(2).round();return r.eq(0)||r.eq(2)?1:-1}(),t}var n=this.toNumber(),i=a.toNumber(),o=Math.pow(n,i);return isFinite(o)?e.fromNumber(o):this.log10().mul(a).pow10()}},{key:"pow_base",value:function(r){return new e(r).pow(this)}},{key:"root",value:function(r){var a=new e(r);return this.pow(a.rec())}},{key:"sqrt",value:function(){return this.pow(.5)}},{key:"cbrt",value:function(){return this.root(3)}},{key:"abs",value:function(){var r=this.clone();return r.sign<0&&(r.sign*=-1),r}},{key:"log10",value:function(){if(this.isneg())return e.NaN.clone();if(this.isZero())return e.NEGATIVE_INFINITY.clone();if(this.small){var r=this.clone();return r.small=!r.small,r.log10().neg()}if(1==this.array.length)return new e(Math.log10(this.array[0].repeat));var a=this.clone();return a.array[1].repeat=a.array[1].repeat-1,a.normalize(),a}},{key:"log",value:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.E,a=new e(r);return this.log10().div(a.log10())}},{key:"exp",value:function(){return this.pow_base(Math.E)}},{key:"mod",value:function(r){var a=new e(r),t=this.div(a);return t.sub(t.floor()).mul(a)}},{key:"factorial",value:function(){return this.abs().lt(t)?this.add(1).gamma():this.abs().lt(e.E_MSI)?e.exp(this.mul(this.log10().sub(1))):e.exp(this)}},{key:"gamma",value:function(){if(this.small)return this.rec();if(this.lte(t)){if(this.lt(24))return e.fromNumber(function(r){if(!isFinite(r))return r;if(r<-50)return r===Math.trunc(r)?Number.NEGATIVE_INFINITY:0;for(var e=1;r<10;)e*=r,++r;var a=.9189385332046727;a+=((r-=1)+.5)*Math.log(r),a-=r;var t=r*r,n=r;return a+=1/(12*n),a-=1/(360*(n*=t)),a+=1/(1260*(n*=t)),a-=1/(1680*(n*=t)),a+=1/(1188*(n*=t)),a-=691/(360360*(n*=t)),a+=7/(1092*(n*=t)),a-=3617/(122400*(n*=t)),Math.exp(a)/e}(this.sign*this.getOperator(0)));var r=this.getOperator(0)-1,a=.9189385332046727;a+=(r+.5)*Math.log(r);var n=r*r,i=r,o=12*i,s=1/o,l=(a-=r)+s;if(l===a)return e.exp(a);if((l=(a=l)-(s=1/(o=360*(i*=n))))===a)return e.exp(a);a=l;var u=1/(o=1260*(i*=n));return a+=u,a-=u=1/(o=1680*(i*=n)),e.exp(a)}return this.gt(t)?e.exp(this.mul(this.log().sub(1))):e.exp(this)}},{key:"lambertw",value:function(){var r=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.lt(-.3678794411710499)?e.NaN.clone():r?this.abs().lt("1e-300")?new e(this):this.small?e.fromNumber(h(this.toNumber())):0===this.layer?e.fromNumber(h(this.sign*this.getOperator(0))):this.lt("eee15")?g(this):this.log():1===this.sign?e.NaN.clone():0===this.layer?e.fromNumber(h(this.sign*this.array[0].repeat,1e-10,!1)):1==this.layer?g(this,1e-10,!1):this.neg().rec().lambertw().neg()}},{key:"max",value:function(r){var a=new e(r);return this.lt(a)?a.clone():this.clone()}},{key:"min",value:function(r){var a=new e(r);return this.gte(a)?a.clone():this.clone()}},{key:"maxabs",value:function(r){var a=new e(r).abs();return this.abs().lt(a)?a.clone():this.clone()}},{key:"minabs",value:function(r){var a=new e(r).abs();return this.abs().gt(a)?a.clone():this.clone()}},{key:"cmpabs",value:function(r){var a=new e(r).abs();return this.abs().cmp(a)}},{key:"neg",value:function(){var r=this.clone();return r.sign*=-1,r.normalize(),r}},{key:"rec",value:function(){var r=this.clone();return r.small=!r.small,r}},{key:"floor",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?e.ZERO.clone():e.ONE.neg().clone();var r=this.abs();return r.array[0].repeat=Math[1==this.sign?"floor":"ceil"](r.getOperator(0)),r}},{key:"ceil",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?e.ONE.clone():e.ZERO.clone();var r=this.abs();return r.array[0].repeat=Math[1==this.sign?"ceil":"floor"](r.getOperator(0)),r.sign=this.sign,r}},{key:"round",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?this.rec().lte(2)?e.ONE.clone():e.ZERO.clone():this.abs().rec().lte(2)?e.ZERO.clone():e.ONE.neg().clone();var r=this.abs();return r.array[0].repeat=Math.round(r.array[0].repeat),r.sign=this.sign,r}},{key:"trunc",value:function(){var r=this.clone();return r.gte(0)?r.floor():r.ceil()}},{key:"compare",value:function(r){var a=new e(r);if(this.isNaN()||a.isNaN())return 2;if(this.sign<a.sign)return-1;if(this.sign>a.sign)return 1;var t=-1==this.sign&&-1==a.sign;if(this.small&&!a.small)return-1*(t?-1:1);if(a.small&&!this.small)return 1*(t?-1:1);var n=1;this.small&&a.small&&(n*=-1),t&&(n*=-1);for(var i=0,o=0;this.array.length-1-o>=0&&a.array.length-1-o>=0;o++){var l=this.array[this.array.length-1-o],u=a.array[a.array.length-1-o],h=s([l.megota,l.expans,l.arrow,l.repeat],[u.megota,u.expans,u.arrow,u.repeat]);if(1==h){i=1;break}if(-1==h){i=-1;break}}return i*n+1-1}},{key:"cmp",value:function(r){return this.compare(r)}},{key:"eq",value:function(r){return 0===this.cmp(r)}},{key:"neq",value:function(r){return 0!==this.cmp(r)}},{key:"lt",value:function(r){return-1===this.cmp(r)}},{key:"lte",value:function(r){return this.cmp(r)<=0}},{key:"gt",value:function(r){return 1==this.cmp(r)}},{key:"gte",value:function(r){var e=this.cmp(r);return 0==e||1==e}},{key:"isNaN",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return isNaN(this.getOperator(0))}))},{key:"isZero",value:function(){return Boolean(this.small&&!isFinite(this.getOperator(0)))}},{key:"isFinite",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return Boolean(this.small||isFinite(this.getOperator(0)))&&!this.isNaN()}))},{key:"isInfinite",value:function(){return Boolean(!this.small&&!isFinite(this.getOperator(0)))||this.isNaN()}},{key:"isInt",value:function(){return!!this.isZero()||(!(this.small||!Number.isInteger(this.getOperator(0)))||!!this.abs().gte(t/2))}},{key:"ispos",value:function(){return this.sign>0}},{key:"isneg",value:function(){return this.sign<0}},{key:"normalize",value:function(){for(var r=!0,a=this,i=0;i<this.array.length;i++)if(this.array[i].repeat==1/0)return this.array=[{arrow:0,expans:1,megota:1,repeat:1/0}],this.layer=0,this;for(var l=1;l<a.array.length;++l){var u=a.array[l];if(null!==u.arrow&&void 0!==u.arrow||(u.arrow=0),null!==u.expans&&void 0!==u.expans||(u.expans=1),null!==u.megota&&void 0!==u.megota||(u.megota=1),isNaN(u.arrow)||isNaN(u.repeat)||isNaN(u.expans)||isNaN(u.megota))return a.array=[o(NaN,0,1,1)],a;if(!isFinite(u.repeat)||!isFinite(u.megota))return a.array=[o(1/0,0,1,1)],a;Number.isInteger(u.arrow)||(u.arrow=Math.floor(u.arrow)),Number.isInteger(u.repeat)||(u.repeat=Math.floor(u.repeat)),Number.isInteger(u.expans)||(u.expans=Math.floor(u.expans)),Number.isInteger(u.megota)||(u.megota=Math.floor(u.megota))}do{for(r=!1,this.array.sort((function(r,e){return s([r.megota,r.expans,r.arrow],[e.megota,e.expans,e.arrow])})),l=1;l<a.array.length;++l)0===a.array[l].arrow||0!==a.array[l].repeat&&null!==a.array[l].repeat&&void 0!==a.array[l].repeat?0==a.array[l].arrow&&a.array[l].expans>=2&&(a.array[l].arrow=1/0,a.array[l].valuereplaced=0,a.array[l].expans=a.array[l].expans-1):(a.array.splice(l,1),--l);for(var h=1;h<this.array.length;h++)0==this.array[h].repeat&&(this.array.splice(h,1),h--);for(a.array.length||(a.small=!a.small,a.array=[o(1/0)]),a.array.length>e.maxOps&&a.array.splice(1,a.array.length-e.maxOps),this.getOperator(1)>=1&&this.getOperator(0)<n&&(this.setOperator(this.getOperator(1)-1,1),this.setOperator(Math.pow(10,this.getOperator(0)),0),r=!0),this.getOperator(0)>t&&(this.setOperator(this.getOperator(1)+1,1),this.setOperator(Math.log10(this.getOperator(0)),0),r=!0),1==this.array.length&&this.array[0].repeat<1&&(this.array[0].repeat=1/this.array[0].repeat,this.small=!this.small,r=!0);a.array.length>=2&&1==a.array[0].repeat&&a.array[1].repeat;)a.array[1].repeat>1?a.array[1].repeat--:a.array.splice(1,1),a.array[0].repeat=10,r=!0;for(a.array.length>=2&&a.array[0].repeat<t&&a.array[1].arrow>=2&&1==a.array[1].repeat&&(a.array.splice(1,1,o(a.array[0].repeat,a.array[1].arrow-1,a.array[1].expans,a.array[1].megota)),a.array[0].repeat=10,r=!0),l=1;l<a.array.length-1;++l)a.array[l].arrow==a.array[l+1].arrow&&a.array[l].expans==a.array[l+1].expans&&a.array[l].megota==a.array[l+1].megota&&(a.array[l].repeat+=a.array[l+1].repeat,a.array.splice(l+1,1),--l,r=!0)}while(r);return this}},{key:"getOperatorIndex",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(1==this.array.length&&0==r)return 0;if(1==this.array.length&&1==r)return.5;if(2==this.array.length&&1==r)return 1;if(2==this.array.length&&0==r)return 0;for(var t=0;t<this.array.length;t++){var n=s([this.array[t].megota,this.array[t].expans,this.array[t].arrow],[a,e,r]);if(0==n)return t;if(1==n)return t-.5}return this.array.length-.5}},{key:"getOperator",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,t=this.getOperatorIndex(r,e,a);return this.array[t]?this.array[t].repeat:0}},{key:"setOperator",value:function(r,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=this.getOperatorIndex(e,a,t);return this.array[n]?(this.array[n].repeat=r,!1):(this.array.splice(Math.ceil(n),0,{arrow:e,expans:a,megota:t,valuereplaced:a===1/0?1:e==1/0?0:-1,repeat:r}),!0)}},{key:"clone",value:function(){var r=new e;return r.resetFromObject(this),r}},{key:"resetFromObject",value:function(r){this.array=[];for(var e=0;e<r.array.length;e++)this.array[e]={arrow:r.array[e].arrow,expans:r.array[e].expans,megota:r.array[e].megota,repeat:r.array[e].repeat,valuereplaced:r.array[e].valuereplaced};return this.small=r.small,this.sign=r.sign,this.layer=r.layer,this}},{key:"toNumber",value:function(){return-1==this.sign?-this.neg().toNumber():this.small?1/this.rec().toNumber():this.array.length>2?1/0:1==this.array.length?this.array[0].repeat:2==this.array.length&&1==this.array[1].arrow&&1==this.array[1].expans&&1==this.array[1].megota&&1==this.array[1].repeat?Math.pow(10,this.getOperator(0)):NaN}},{key:"toString",value:function(){if(this.isNaN())return"NaN";if(-1==this.sign)return"-".concat(this.neg().toString());if(this.small)return this.eq(e.ZERO)?"0":"/".concat(this.rec().toString());if(this.isInfinite())return"Infinity";for(var r="",a=this.array.length-1;a>=0;a--){var t=this.array[a],n="10{".concat(t.arrow===1/0?"!":t.arrow).concat(t.expans>1||t.megota>1?",".concat(t.expans===1/0?"!":t.expans):"").concat(t.megota>1?",".concat(t.megota):"","}");n=1==t.arrow&&1==t.expans&&1==t.megota&&t.repeat<5?"e".repeat(t.repeat):0==t.arrow&&1==t.expans&&1==t.megota?t.repeat.toString():t.repeat>1?"(".concat(n,")^").concat(t.repeat," "):"".concat(n," "),r+="".concat(n)}return r}},{key:"arr01",get:function(){for(var r=[0],e=0;e<this.array.length;e++)0==e?r[0]=this.array[e].repeat:(r[e]=[0,0,0,0],r[e][0]=this.array[e].arrow==1/0?"x":this.array[e].arrow,r[e][1]=this.array[e].repeat,r[e][2]=this.array[e].expans==1/0?"x":this.array[e].expans,r[e][3]=this.array[e].megota);return r}}],[{key:"add",value:function(r,a){return new e(r).add(a)}},{key:"sub",value:function(r,a){return new e(r).sub(a)}},{key:"mul",value:function(r,a){return new e(r).mul(a)}},{key:"div",value:function(r,a){return new e(r).div(a)}},{key:"pow",value:function(r,a){return new e(r).pow(a)}},{key:"root",value:function(r,a){return new e(r).root(a)}},{key:"sqrt",value:function(r){return new e(r).sqrt()}},{key:"cbrt",value:function(r){return new e(r).cbrt()}},{key:"log10",value:function(r){return new e(r).log10()}},{key:"log",value:function(r){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new e(r).log(a)}},{key:"exp",value:function(r){return new e(r).pow_base(Math.E)}},{key:"factorial",value:function(r){return new e(r).factorial()}},{key:"gamma",value:function(r){return new e(r).gamma()}},{key:"lambertw",value:function(r){var a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new e(r).lambertw(a)}},{key:"tetrate_10",value:function(r){var a=new e(r),t=a.trunc().toNumber(),n=a.sub(t).toNumber();if(a.gt(e.PENTATED_MSI))return a.clone();if(!a.gt(e.MSI)){if(a.lt(-2))return e.NaN.clone();if(a.lt(-1))return a.add(2).log10();if(a.lt(0))return a.add(1);if(a.lt(1))return a.pow10();if(1==t)return e.pow(10,e.pow(10,n));if(2==t)return e.pow(10,e.pow(10,e.pow(10,n)));var i=t-2,o=e.pow(10,e.pow(10,e.pow(10,n)));return o.setOperator(o.getOperator(1)+i,1),o}return a.setOperator(a.getOperator(2)+1,2),e.NaN.clone()}},{key:"isNaN",value:function(r){return new e(r).isNaN()}},{key:"fromNumber",value:function(r){var a=new e;if(r<0)a.sign=-1;else{if(0==r)return a.sign=0,a.small=!0,a.array=[o(1/0,0)],a;r>0&&(a.sign=1)}var n=Math.abs(r);return n>=11102230246251568e-32&&n<1?(a.small=!0,a.array=[o(1/n,0)]):n<11102230246251568e-32?(a.small=!0,a.array=[o(-Math.log10(n),0),o(1,1)]):n<=t?a.array=[o(n,0)]:(a.setOperator(Math.log10(n),0),a.array=[o(Math.log10(n),0),o(1,1)]),a}},{key:"fromString",value:function(r){var a,s,u,h,g,y,p=new e;if(!isNaN(Number(r))&&isFinite(Number(r)))return p.resetFromObject(e.fromNumber(Number(r))),p;if(!i.test(r))throw"[PowiainaNum 0.2 error]malformed input: "+r;var f=!1,c=!1;if("-"==r[0]||"+"==r[0]){var m=r.search(/[^-\+]/);f=(null!==(s=null===(a=r.substring(0,m).match(/-/g))||void 0===a?void 0:a.length)&&void 0!==s?s:0)%2==1,r=r.substring(m)}if("/"==r[0]){m=r.search(/[^\/]/);c=(null!==(h=null===(u=r.substring(0,m).match(/\//g))||void 0===u?void 0:u.length)&&void 0!==h?h:0)%2==1,r=r.substring(m)}if("NaN"==r)p.array=[o(NaN)];else if("Infinity"==r)p.array=[o(1/0)];else{var v,w,N,b;for(p.sign=1,p.array=[o(0)];r&&/^(\(?10[\^\{])/.test(r);){var d,I,E;if("("==r[0]&&(r=r.substring(1)),"^"==r[2])d=v=r.substring(2).search(/[^\^]/),w=v+2;else{v=r.indexOf("}");var M=r.substring(3,v).split(",");d=Number("!"==M[0]?1/0:M[0]),I=Number(null!==(g="!"==M[1]?1/0:M[1])&&void 0!==g?g:1),E=Number(null!==(y=M[2])&&void 0!==y?y:1),w=v+1}")"==(r=r.substring(w))[0]?(v=r.indexOf(" "),N=Number(r.substring(2,v)),r=r.substring(v+1)):N=1,1==d&&1==I&&1==E?p.array.length>=2&&1==p.array[1].arrow?p.array[1].repeat+=N:p.array.splice(1,0,o(N,1,I,E)):2==d&&1==I&&1==E?(v=p.array.length>=2&&1==p.array[1].arrow?p.array[1].repeat:0,(w=p.array[0].repeat)>=1e10&&++v,w>=10&&++v,p.array[0].repeat=v,p.array.length>=2&&1==p.array[1].arrow&&p.array.splice(1,1),b=p.getOperatorIndex(2),Number.isInteger(b)?p.array[b].repeat+=N:p.array.splice(Math.ceil(b),0,o(N,2,I,E))):isFinite(d)?(v=p.getOperator(d-1),(w=p.getOperator(d-2))>=10&&++v,b=p.getOperatorIndex(d),p.array.splice(1,Math.ceil(b)-1),p.array[0].repeat=v,Number.isInteger(b)?p.array[1].repeat+=N:p.array.splice(1,0,o(N,d,I,E))):p.array.splice(1,0,o(N,d,I,E))}v=r.split(/[Ee]/),w=[p.array[0].repeat,0],N=1;for(var O=v.length-1;O>=0;--O){w[0]<n&&0===w[1]?w[0]=Math.pow(10,N*w[0]):-1==N?(0===w[1]?w[0]=Math.pow(10,N*w[0]):1==w[1]&&w[0]<=Math.log10(Number.MAX_VALUE)?w[0]=Math.pow(10,N*Math.pow(10,w[0])):w[0]=0,w[1]=0):w[1]++;var x=v[O].indexOf("."),k=-1==x?v[O].length:x;0===w[1]?k>=17?(w[0]=Math.log10(w[0])+l(v[O].substring(0,k)),w[1]=1):v[O]&&(w[0]*=Number(v[O])):(b=k>=17?l(v[O].substring(0,k)):v[O]?Math.log10(Number(v[O])):0,1==w[1]?w[0]+=b:2==w[1]&&w[0]<n+Math.log10(b)&&(w[0]+=Math.log10(1+Math.pow(10,Math.log10(b)-w[0])))),w[0]<n&&w[1]?(w[0]=Math.pow(10,w[0]),w[1]--):w[0]>t&&(w[0]=Math.log10(w[0]),w[1]++)}p.array[0].repeat=w[0],w[1]&&(p.array.length>=2&&1==p.array[1].arrow?p.array[1].repeat+=w[1]:p.array.splice(1,0,o(w[1],1,1,1)))}return f&&(p.sign*=-1),c&&(p.small=!p.small),p.normalize(),p.normalize(),p}},{key:"fromObject",value:function(r){var a=new e;a.array=[];for(var t=0;t<r.array.length;t++)a.array[t]={arrow:r.array[t].arrow,expans:r.array[t].expans,megota:r.array[t].megota,repeat:r.array[t].repeat,valuereplaced:r.array[t].valuereplaced};return a.small=r.small,a.sign=r.sign,a.layer=r.layer,a}}])}();return p.ZERO=new p({array:[{arrow:0,expans:1,megota:1,repeat:1/0}],small:!0,layer:0,sign:0}),p.ONE=new p({array:[{arrow:0,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),p.MSI=new p(t),p.MSI_REC=((y=new p(t)).small=!0,y),p.E_MSI=new p({array:[{arrow:0,expans:1,megota:1,repeat:t},{arrow:1,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),p.E_MSI_REC=new p({array:[{arrow:0,expans:1,megota:1,repeat:t},{arrow:1,expans:1,megota:1,repeat:1}],small:!0,layer:0,sign:1}),p.TETRATED_MSI=new p({array:[{arrow:0,expans:1,megota:1,repeat:t},{arrow:1,expans:1,megota:1,repeat:t}],small:!1,layer:0,sign:1}),p.PENTATED_MSI=new p({array:[{arrow:0,expans:1,megota:1,repeat:t},{arrow:1,expans:1,megota:1,repeat:t},{arrow:2,expans:1,megota:1,repeat:t}],small:!1,layer:0,sign:1}),p.TRITRI=new p({small:!1,layer:0,sign:1,array:[o(3638334640023.7783,0,1,1),o(7625587484984,1,1,1)]}),p.GRAHAMS_NUMBER=new p("(10{!})^63 10^^^(10^)^7625597484984 3638334640023.7783"),p.POSITIVE_INFINITY=new p(1/0),p.NEGATIVE_INFINITY=new p(-1/0),p.NaN=new p({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),p.maxOps=100,p}));
|
package/dist/index.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export default class PowiainaNum implements IPowiainaNum {
|
|
|
71
71
|
*/
|
|
72
72
|
lambertw(princ?: boolean): PowiainaNum;
|
|
73
73
|
static lambertw(x: PowiainaNumSource, principal?: boolean): PowiainaNum;
|
|
74
|
+
static tetrate_10(other2: PowiainaNumSource): PowiainaNum;
|
|
74
75
|
max(x: PowiainaNumSource): PowiainaNum;
|
|
75
76
|
min(x: PowiainaNumSource): PowiainaNum;
|
|
76
77
|
maxabs(x: PowiainaNumSource): PowiainaNum;
|
|
@@ -81,6 +82,7 @@ export default class PowiainaNum implements IPowiainaNum {
|
|
|
81
82
|
floor(): PowiainaNum;
|
|
82
83
|
ceil(): PowiainaNum;
|
|
83
84
|
round(): PowiainaNum;
|
|
85
|
+
trunc(): PowiainaNum;
|
|
84
86
|
/**
|
|
85
87
|
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
86
88
|
*/
|
|
@@ -139,6 +141,8 @@ export default class PowiainaNum implements IPowiainaNum {
|
|
|
139
141
|
static readonly MSI_REC: PowiainaNum;
|
|
140
142
|
static readonly E_MSI: PowiainaNum;
|
|
141
143
|
static readonly E_MSI_REC: PowiainaNum;
|
|
144
|
+
static readonly TETRATED_MSI: PowiainaNum;
|
|
145
|
+
static readonly PENTATED_MSI: PowiainaNum;
|
|
142
146
|
static readonly TRITRI: PowiainaNum;
|
|
143
147
|
static readonly GRAHAMS_NUMBER: PowiainaNum;
|
|
144
148
|
static readonly POSITIVE_INFINITY: PowiainaNum;
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "powiaina_num.js",
|
|
3
|
-
"version": "0.2.0-alpha.2.
|
|
4
|
-
"description": "A JavaScript library that handles arithmetic for numbers as large as {10,9e15,1,1,1,2}.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/PowiainaNum.js",
|
|
7
|
-
"module": "dist/PowiainaNum.esm.js",
|
|
8
|
-
"exports": {
|
|
9
|
-
"import": "./dist/PowiainaNum.esm.js",
|
|
10
|
-
"require": "./dist/PowiainaNum.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
},
|
|
13
|
-
"unpkg": "dist/PowiainaNum.min.js",
|
|
14
|
-
"types": "dist/index.d.ts",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "bili",
|
|
17
|
-
"prepublishOnly": "npm run build",
|
|
18
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
19
|
-
"fix": "prettier --write ."
|
|
20
|
-
},
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/VeryrrDefine/PowiainaNum.js.git"
|
|
24
|
-
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
"bignum",
|
|
27
|
-
"bignumber",
|
|
28
|
-
"bigdecimal",
|
|
29
|
-
"number",
|
|
30
|
-
"decimal"
|
|
31
|
-
],
|
|
32
|
-
"files": [
|
|
33
|
-
"dist"
|
|
34
|
-
],
|
|
35
|
-
"author": "VeryrrDefine",
|
|
36
|
-
"license": "MIT",
|
|
37
|
-
"bugs": {
|
|
38
|
-
"url": "https://github.com/VeryrrDefine/PowiainaNum.js/issues"
|
|
39
|
-
},
|
|
40
|
-
"homepage": "https://github.com/VeryrrDefine/PowiainaNum.js#readme",
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"prettier": "^3.6.2",
|
|
43
|
-
"rollup-plugin-typescript2": "^0.36.0",
|
|
44
|
-
"typescript": "^5.8.3",
|
|
45
|
-
"bili": "^5.0.5"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "powiaina_num.js",
|
|
3
|
+
"version": "0.2.0-alpha.2.7",
|
|
4
|
+
"description": "A JavaScript library that handles arithmetic for numbers as large as {10,9e15,1,1,1,2}.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/PowiainaNum.js",
|
|
7
|
+
"module": "dist/PowiainaNum.esm.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": "./dist/PowiainaNum.esm.js",
|
|
10
|
+
"require": "./dist/PowiainaNum.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"unpkg": "dist/PowiainaNum.min.js",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "bili",
|
|
17
|
+
"prepublishOnly": "npm run build",
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
19
|
+
"fix": "prettier --write ."
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/VeryrrDefine/PowiainaNum.js.git"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"bignum",
|
|
27
|
+
"bignumber",
|
|
28
|
+
"bigdecimal",
|
|
29
|
+
"number",
|
|
30
|
+
"decimal"
|
|
31
|
+
],
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"author": "VeryrrDefine",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/VeryrrDefine/PowiainaNum.js/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/VeryrrDefine/PowiainaNum.js#readme",
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"prettier": "^3.6.2",
|
|
43
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
44
|
+
"typescript": "^5.8.3",
|
|
45
|
+
"bili": "^5.0.5"
|
|
46
|
+
}
|
|
47
|
+
}
|