powiaina_num.js 0.2.0-alpha.3 → 0.2.0-alpha.3.1
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 +1 -1
- package/dist/PowiainaNum.cjs.js +208 -24
- package/dist/PowiainaNum.esm.js +208 -24
- package/dist/PowiainaNum.js +208 -24
- package/dist/PowiainaNum.min.js +1 -1
- package/dist/index.d.ts +117 -5
- package/package.json +1 -1
package/dist/PowiainaNum.esm.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
function _arrayLikeToArray(r, a) {
|
|
2
|
+
(null == a || a > r.length) && (a = r.length);
|
|
3
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
4
|
+
return n;
|
|
5
|
+
}
|
|
6
|
+
function _arrayWithoutHoles(r) {
|
|
7
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
8
|
+
}
|
|
1
9
|
function _classCallCheck(a, n) {
|
|
2
10
|
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
3
11
|
}
|
|
@@ -12,6 +20,15 @@ function _createClass(e, r, t) {
|
|
|
12
20
|
writable: !1
|
|
13
21
|
}), e;
|
|
14
22
|
}
|
|
23
|
+
function _iterableToArray(r) {
|
|
24
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
25
|
+
}
|
|
26
|
+
function _nonIterableSpread() {
|
|
27
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
28
|
+
}
|
|
29
|
+
function _toConsumableArray(r) {
|
|
30
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
31
|
+
}
|
|
15
32
|
function _toPrimitive(t, r) {
|
|
16
33
|
if ("object" != typeof t || !t) return t;
|
|
17
34
|
var e = t[Symbol.toPrimitive];
|
|
@@ -35,6 +52,13 @@ function _typeof(o) {
|
|
|
35
52
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
36
53
|
}, _typeof(o);
|
|
37
54
|
}
|
|
55
|
+
function _unsupportedIterableToArray(r, a) {
|
|
56
|
+
if (r) {
|
|
57
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
58
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
59
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
38
62
|
|
|
39
63
|
var powiainaNumError = "[PowiainaNum 0.2 error]";
|
|
40
64
|
var MSI = 9007199254740991;
|
|
@@ -226,8 +250,13 @@ function d_lambertw(z) {
|
|
|
226
250
|
throw Error("Iteration failed to converge: ".concat(z.toString())); //return Decimal.dNaN;
|
|
227
251
|
}
|
|
228
252
|
var PowiainaNum = /*#__PURE__*/function () {
|
|
253
|
+
/**
|
|
254
|
+
* Constructor of PowiainaNum class,
|
|
255
|
+
* If no arguments, return `PowiainaNum.NaN`.
|
|
256
|
+
*/
|
|
229
257
|
function PowiainaNum(arg1) {
|
|
230
258
|
_classCallCheck(this, PowiainaNum);
|
|
259
|
+
this.a = Number.MAX_SAFE_INTEGER;
|
|
231
260
|
this.array = [{
|
|
232
261
|
arrow: 0,
|
|
233
262
|
expans: 1,
|
|
@@ -362,7 +391,11 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
362
391
|
}
|
|
363
392
|
}, {
|
|
364
393
|
key: "pow10",
|
|
365
|
-
value:
|
|
394
|
+
value:
|
|
395
|
+
/**
|
|
396
|
+
* @returns 10 to the power of `this`
|
|
397
|
+
*/
|
|
398
|
+
function pow10() {
|
|
366
399
|
var _a, _b;
|
|
367
400
|
var r = this.clone();
|
|
368
401
|
// inf & nan check
|
|
@@ -800,29 +833,51 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
800
833
|
value: function chain(other, arrows) {
|
|
801
834
|
return this.arrow(arrows)(other);
|
|
802
835
|
}
|
|
836
|
+
/**
|
|
837
|
+
* Select the largest number of arguments.
|
|
838
|
+
*/
|
|
803
839
|
}, {
|
|
804
840
|
key: "max",
|
|
805
|
-
value: function max(
|
|
806
|
-
var
|
|
807
|
-
|
|
841
|
+
value: function max() {
|
|
842
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
843
|
+
args[_key2] = arguments[_key2];
|
|
844
|
+
}
|
|
845
|
+
return PowiainaNum.max.apply(PowiainaNum, [this].concat(args));
|
|
808
846
|
}
|
|
809
847
|
}, {
|
|
810
848
|
key: "min",
|
|
811
|
-
value: function min(
|
|
812
|
-
var
|
|
813
|
-
|
|
849
|
+
value: function min() {
|
|
850
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
851
|
+
args[_key3] = arguments[_key3];
|
|
852
|
+
}
|
|
853
|
+
return PowiainaNum.min.apply(PowiainaNum, [this].concat(args));
|
|
814
854
|
}
|
|
855
|
+
/**
|
|
856
|
+
* Compare what PowiainaNum's absolute value is max
|
|
857
|
+
* @param args
|
|
858
|
+
* @returns absolute value max number's absolute value
|
|
859
|
+
*/
|
|
815
860
|
}, {
|
|
816
861
|
key: "maxabs",
|
|
817
|
-
value: function maxabs(
|
|
818
|
-
var
|
|
819
|
-
|
|
862
|
+
value: function maxabs() {
|
|
863
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
864
|
+
args[_key4] = arguments[_key4];
|
|
865
|
+
}
|
|
866
|
+
var other = args.map(function (x) {
|
|
867
|
+
return new PowiainaNum(x).abs();
|
|
868
|
+
});
|
|
869
|
+
return PowiainaNum.max.apply(PowiainaNum, [this.abs()].concat(_toConsumableArray(other)));
|
|
820
870
|
}
|
|
821
871
|
}, {
|
|
822
872
|
key: "minabs",
|
|
823
|
-
value: function minabs(
|
|
824
|
-
var
|
|
825
|
-
|
|
873
|
+
value: function minabs() {
|
|
874
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
875
|
+
args[_key5] = arguments[_key5];
|
|
876
|
+
}
|
|
877
|
+
var other = args.map(function (x) {
|
|
878
|
+
return new PowiainaNum(x).abs();
|
|
879
|
+
});
|
|
880
|
+
return PowiainaNum.min.apply(PowiainaNum, [this.abs()].concat(_toConsumableArray(other)));
|
|
826
881
|
}
|
|
827
882
|
}, {
|
|
828
883
|
key: "cmpabs",
|
|
@@ -1118,7 +1173,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1118
1173
|
this.setOperator(Math.pow(10, this.getOperator(0)), 0);
|
|
1119
1174
|
renormalize = true;
|
|
1120
1175
|
}
|
|
1121
|
-
if (this.getOperator(0) > MSI) {
|
|
1176
|
+
if (this.getOperator(0) > MSI && !isFinite(this.getOperator(0))) {
|
|
1122
1177
|
this.setOperator(this.getOperator(1) + 1, 1);
|
|
1123
1178
|
this.setOperator(Math.log10(this.getOperator(0)), 0);
|
|
1124
1179
|
renormalize = true;
|
|
@@ -1303,7 +1358,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1303
1358
|
key: "arr01",
|
|
1304
1359
|
get:
|
|
1305
1360
|
/**
|
|
1306
|
-
* A property
|
|
1361
|
+
* A property array value for version 0.1.x PowiainaNum.
|
|
1307
1362
|
*/
|
|
1308
1363
|
function get() {
|
|
1309
1364
|
var res = [0];
|
|
@@ -1437,6 +1492,64 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1437
1492
|
// 2--3, 1e10-<e1e10, 10^10^10^0->1
|
|
1438
1493
|
return PowiainaNum.NaN.clone();*/
|
|
1439
1494
|
}
|
|
1495
|
+
}, {
|
|
1496
|
+
key: "max",
|
|
1497
|
+
value: function max() {
|
|
1498
|
+
var max = PowiainaNum.NEGATIVE_INFINITY;
|
|
1499
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
1500
|
+
args[_key6] = arguments[_key6];
|
|
1501
|
+
}
|
|
1502
|
+
for (var i = 0; i < args.length; i++) {
|
|
1503
|
+
if (max.lt(args[i])) {
|
|
1504
|
+
max = new PowiainaNum(args[i]).clone();
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
return max;
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Select the smallest number of arguments.
|
|
1511
|
+
*/
|
|
1512
|
+
}, {
|
|
1513
|
+
key: "min",
|
|
1514
|
+
value: function min() {
|
|
1515
|
+
var max = PowiainaNum.POSITIVE_INFINITY;
|
|
1516
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
1517
|
+
args[_key7] = arguments[_key7];
|
|
1518
|
+
}
|
|
1519
|
+
for (var i = 0; i < args.length; i++) {
|
|
1520
|
+
if (max.gt(args[i])) {
|
|
1521
|
+
max = new PowiainaNum(args[i]).clone();
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
return max;
|
|
1525
|
+
}
|
|
1526
|
+
/**
|
|
1527
|
+
* Restrict a number be not lower than a number
|
|
1528
|
+
*
|
|
1529
|
+
* It's also an alias of `PowiainaNum.max`.
|
|
1530
|
+
* @returns restricted number
|
|
1531
|
+
*/
|
|
1532
|
+
}, {
|
|
1533
|
+
key: "clampMin",
|
|
1534
|
+
value: function clampMin() {
|
|
1535
|
+
return PowiainaNum.max.apply(PowiainaNum, arguments);
|
|
1536
|
+
}
|
|
1537
|
+
/**
|
|
1538
|
+
* Restrict a number be not higher than a number
|
|
1539
|
+
*
|
|
1540
|
+
* It's also an alias of `PowiainaNum.min`.
|
|
1541
|
+
* @returns restricted number
|
|
1542
|
+
*/
|
|
1543
|
+
}, {
|
|
1544
|
+
key: "clampMax",
|
|
1545
|
+
value: function clampMax() {
|
|
1546
|
+
return PowiainaNum.min.apply(PowiainaNum, arguments);
|
|
1547
|
+
}
|
|
1548
|
+
}, {
|
|
1549
|
+
key: "sign",
|
|
1550
|
+
value: function sign(a) {
|
|
1551
|
+
return new PowiainaNum(a).sign;
|
|
1552
|
+
}
|
|
1440
1553
|
}, {
|
|
1441
1554
|
key: "isNaN",
|
|
1442
1555
|
value: function isNaN(x) {
|
|
@@ -1704,6 +1817,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1704
1817
|
}
|
|
1705
1818
|
}]);
|
|
1706
1819
|
}();
|
|
1820
|
+
/**
|
|
1821
|
+
* Zero
|
|
1822
|
+
*/
|
|
1707
1823
|
PowiainaNum.ZERO = new PowiainaNum({
|
|
1708
1824
|
array: [{
|
|
1709
1825
|
arrow: 0,
|
|
@@ -1715,6 +1831,9 @@ PowiainaNum.ZERO = new PowiainaNum({
|
|
|
1715
1831
|
layer: 0,
|
|
1716
1832
|
sign: 0
|
|
1717
1833
|
});
|
|
1834
|
+
/**
|
|
1835
|
+
* One
|
|
1836
|
+
*/
|
|
1718
1837
|
PowiainaNum.ONE = new PowiainaNum({
|
|
1719
1838
|
array: [{
|
|
1720
1839
|
arrow: 0,
|
|
@@ -1726,12 +1845,22 @@ PowiainaNum.ONE = new PowiainaNum({
|
|
|
1726
1845
|
layer: 0,
|
|
1727
1846
|
sign: 1
|
|
1728
1847
|
});
|
|
1848
|
+
/**
|
|
1849
|
+
* The value of the largest integer n such that n and n + 1 are both
|
|
1850
|
+
* exactly representable as a Number value = 9007199254740991 = 2^53 − 1.
|
|
1851
|
+
*/
|
|
1729
1852
|
PowiainaNum.MSI = new PowiainaNum(MSI);
|
|
1853
|
+
/**
|
|
1854
|
+
* MSI's reciprocate value, = 1/9007199254740991.
|
|
1855
|
+
*/
|
|
1730
1856
|
PowiainaNum.MSI_REC = function () {
|
|
1731
1857
|
var obj = new PowiainaNum(MSI);
|
|
1732
1858
|
obj.small = true;
|
|
1733
1859
|
return obj;
|
|
1734
1860
|
}();
|
|
1861
|
+
/**
|
|
1862
|
+
* 10^(MSI) = 10^9007199254740991.
|
|
1863
|
+
*/
|
|
1735
1864
|
PowiainaNum.E_MSI = new PowiainaNum({
|
|
1736
1865
|
array: [{
|
|
1737
1866
|
arrow: 0,
|
|
@@ -1748,6 +1877,9 @@ PowiainaNum.E_MSI = new PowiainaNum({
|
|
|
1748
1877
|
layer: 0,
|
|
1749
1878
|
sign: 1
|
|
1750
1879
|
});
|
|
1880
|
+
/**
|
|
1881
|
+
* 10^(MSI) 's reciprocate value, = 10^-9007199254740991.
|
|
1882
|
+
*/
|
|
1751
1883
|
PowiainaNum.E_MSI_REC = new PowiainaNum({
|
|
1752
1884
|
array: [{
|
|
1753
1885
|
arrow: 0,
|
|
@@ -1764,51 +1896,69 @@ PowiainaNum.E_MSI_REC = new PowiainaNum({
|
|
|
1764
1896
|
layer: 0,
|
|
1765
1897
|
sign: 1
|
|
1766
1898
|
});
|
|
1899
|
+
/**
|
|
1900
|
+
* Tetrated MSI, = 10↑↑9007199254740991.
|
|
1901
|
+
*/
|
|
1767
1902
|
PowiainaNum.TETRATED_MSI = new PowiainaNum({
|
|
1768
1903
|
array: [{
|
|
1769
1904
|
arrow: 0,
|
|
1770
1905
|
expans: 1,
|
|
1771
1906
|
megota: 1,
|
|
1772
|
-
repeat:
|
|
1907
|
+
repeat: 1e10
|
|
1773
1908
|
}, {
|
|
1774
1909
|
arrow: 1,
|
|
1775
1910
|
expans: 1,
|
|
1776
1911
|
megota: 1,
|
|
1777
|
-
repeat: MSI
|
|
1912
|
+
repeat: MSI - 2
|
|
1778
1913
|
}],
|
|
1779
1914
|
small: false,
|
|
1780
1915
|
layer: 0,
|
|
1781
1916
|
sign: 1
|
|
1782
1917
|
});
|
|
1918
|
+
/**
|
|
1919
|
+
* Pentated MSI, = 10↑↑↑9007199254740991.
|
|
1920
|
+
*/
|
|
1783
1921
|
PowiainaNum.PENTATED_MSI = new PowiainaNum({
|
|
1784
1922
|
array: [{
|
|
1785
1923
|
arrow: 0,
|
|
1786
1924
|
expans: 1,
|
|
1787
1925
|
megota: 1,
|
|
1788
|
-
repeat:
|
|
1789
|
-
}, {
|
|
1790
|
-
arrow: 1,
|
|
1791
|
-
expans: 1,
|
|
1792
|
-
megota: 1,
|
|
1793
|
-
repeat: MSI
|
|
1926
|
+
repeat: 10
|
|
1794
1927
|
}, {
|
|
1795
1928
|
arrow: 2,
|
|
1796
1929
|
expans: 1,
|
|
1797
1930
|
megota: 1,
|
|
1798
|
-
repeat: MSI
|
|
1931
|
+
repeat: MSI - 1
|
|
1799
1932
|
}],
|
|
1800
1933
|
small: false,
|
|
1801
1934
|
layer: 0,
|
|
1802
1935
|
sign: 1
|
|
1803
1936
|
});
|
|
1937
|
+
/**
|
|
1938
|
+
* Tritri, = 3↑↑↑3 = power tower with height 7625597484987 base 3.
|
|
1939
|
+
*/
|
|
1804
1940
|
PowiainaNum.TRITRI = new PowiainaNum({
|
|
1805
1941
|
small: false,
|
|
1806
1942
|
layer: 0,
|
|
1807
1943
|
sign: 1,
|
|
1808
1944
|
array: [newOperator(3638334640023.7783, 0, 1, 1), newOperator(7625587484984, 1, 1, 1)]
|
|
1809
1945
|
});
|
|
1946
|
+
/**
|
|
1947
|
+
* The Graham's Number, = G^64(4)
|
|
1948
|
+
*
|
|
1949
|
+
* = 3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{
|
|
1950
|
+
* 3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3{3↑↑↑↑3
|
|
1951
|
+
* }3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3
|
|
1952
|
+
* }3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3}3
|
|
1953
|
+
*/
|
|
1810
1954
|
PowiainaNum.GRAHAMS_NUMBER = new PowiainaNum("(10{!})^63 10^^^(10^)^7625597484984 3638334640023.7783");
|
|
1955
|
+
/**
|
|
1956
|
+
* Positive Infinity.
|
|
1957
|
+
*/
|
|
1811
1958
|
PowiainaNum.POSITIVE_INFINITY = new PowiainaNum(Infinity);
|
|
1959
|
+
/**
|
|
1960
|
+
* Negative Infinity.
|
|
1961
|
+
*/
|
|
1812
1962
|
PowiainaNum.NEGATIVE_INFINITY = new PowiainaNum(-Infinity);
|
|
1813
1963
|
PowiainaNum.NaN = new PowiainaNum({
|
|
1814
1964
|
array: [{
|
|
@@ -1821,6 +1971,40 @@ PowiainaNum.NaN = new PowiainaNum({
|
|
|
1821
1971
|
layer: 0,
|
|
1822
1972
|
sign: 0
|
|
1823
1973
|
});
|
|
1974
|
+
/**
|
|
1975
|
+
* The mathematical constant e. This is Euler's number, the base of natural logarithms.
|
|
1976
|
+
*/
|
|
1977
|
+
PowiainaNum.E = new PowiainaNum(Math.E);
|
|
1978
|
+
/**
|
|
1979
|
+
* The natural logarithm of 2 = ln(2).
|
|
1980
|
+
*/
|
|
1981
|
+
PowiainaNum.LN2 = new PowiainaNum(Math.LN2);
|
|
1982
|
+
/**
|
|
1983
|
+
* The natural logarithm of 10.
|
|
1984
|
+
*/
|
|
1985
|
+
PowiainaNum.LN10 = new PowiainaNum(Math.LN10);
|
|
1986
|
+
/**
|
|
1987
|
+
* The base-2 logarithm of e = log_2(e).
|
|
1988
|
+
*/
|
|
1989
|
+
PowiainaNum.LOG2E = new PowiainaNum(Math.LOG2E);
|
|
1990
|
+
/**
|
|
1991
|
+
* The base-10 logarithm of e = log_10(e).
|
|
1992
|
+
*/
|
|
1993
|
+
PowiainaNum.LOG10E = new PowiainaNum(Math.LOG10E);
|
|
1994
|
+
/**
|
|
1995
|
+
* Pi(). This is the ratio of the circumference of a circle to its diameter.
|
|
1996
|
+
*/
|
|
1997
|
+
PowiainaNum.PI = new PowiainaNum(Math.PI);
|
|
1998
|
+
/**
|
|
1999
|
+
* The square root of 0.5, or, equivalently, one divided by the square root of 2.
|
|
2000
|
+
*
|
|
2001
|
+
* = (√2)/2 = √(0.5)
|
|
2002
|
+
*/
|
|
2003
|
+
PowiainaNum.SQRT1_2 = new PowiainaNum(Math.SQRT1_2);
|
|
2004
|
+
/**
|
|
2005
|
+
* The square root of 2 = √2.
|
|
2006
|
+
*/
|
|
2007
|
+
PowiainaNum.SQRT2 = new PowiainaNum(Math.SQRT2);
|
|
1824
2008
|
PowiainaNum.maxOps = 100;
|
|
1825
2009
|
PowiainaNum.arrowFuncMap = new Map();
|
|
1826
2010
|
|