powiaina_num.js 0.2.0-alpha.3 → 0.2.0-alpha.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/PowiainaNum.cjs.js +208 -25
- package/dist/PowiainaNum.esm.js +208 -25
- package/dist/PowiainaNum.js +208 -25
- package/dist/PowiainaNum.min.js +1 -1
- package/dist/index.d.ts +116 -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,6 +250,10 @@ 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);
|
|
231
259
|
this.array = [{
|
|
@@ -362,7 +390,11 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
362
390
|
}
|
|
363
391
|
}, {
|
|
364
392
|
key: "pow10",
|
|
365
|
-
value:
|
|
393
|
+
value:
|
|
394
|
+
/**
|
|
395
|
+
* @returns 10 to the power of `this`
|
|
396
|
+
*/
|
|
397
|
+
function pow10() {
|
|
366
398
|
var _a, _b;
|
|
367
399
|
var r = this.clone();
|
|
368
400
|
// inf & nan check
|
|
@@ -692,7 +724,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
692
724
|
} else if (principal) {
|
|
693
725
|
if (this.abs().lt("1e-300")) return new PowiainaNum(this);else if (this.small) {
|
|
694
726
|
return PowiainaNum.fromNumber(f_lambertw(this.toNumber()));
|
|
695
|
-
} else if (this.
|
|
727
|
+
} else if (this.lt(MSI)) {
|
|
696
728
|
return PowiainaNum.fromNumber(f_lambertw(this.sign * this.getOperator(0)));
|
|
697
729
|
} else if (this.lt("eee15")) {
|
|
698
730
|
return d_lambertw(this);
|
|
@@ -800,29 +832,51 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
800
832
|
value: function chain(other, arrows) {
|
|
801
833
|
return this.arrow(arrows)(other);
|
|
802
834
|
}
|
|
835
|
+
/**
|
|
836
|
+
* Select the largest number of arguments.
|
|
837
|
+
*/
|
|
803
838
|
}, {
|
|
804
839
|
key: "max",
|
|
805
|
-
value: function max(
|
|
806
|
-
var
|
|
807
|
-
|
|
840
|
+
value: function max() {
|
|
841
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
842
|
+
args[_key2] = arguments[_key2];
|
|
843
|
+
}
|
|
844
|
+
return PowiainaNum.max.apply(PowiainaNum, [this].concat(args));
|
|
808
845
|
}
|
|
809
846
|
}, {
|
|
810
847
|
key: "min",
|
|
811
|
-
value: function min(
|
|
812
|
-
var
|
|
813
|
-
|
|
848
|
+
value: function min() {
|
|
849
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
850
|
+
args[_key3] = arguments[_key3];
|
|
851
|
+
}
|
|
852
|
+
return PowiainaNum.min.apply(PowiainaNum, [this].concat(args));
|
|
814
853
|
}
|
|
854
|
+
/**
|
|
855
|
+
* Compare what PowiainaNum's absolute value is max
|
|
856
|
+
* @param args
|
|
857
|
+
* @returns absolute value max number's absolute value
|
|
858
|
+
*/
|
|
815
859
|
}, {
|
|
816
860
|
key: "maxabs",
|
|
817
|
-
value: function maxabs(
|
|
818
|
-
var
|
|
819
|
-
|
|
861
|
+
value: function maxabs() {
|
|
862
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
863
|
+
args[_key4] = arguments[_key4];
|
|
864
|
+
}
|
|
865
|
+
var other = args.map(function (x) {
|
|
866
|
+
return new PowiainaNum(x).abs();
|
|
867
|
+
});
|
|
868
|
+
return PowiainaNum.max.apply(PowiainaNum, [this.abs()].concat(_toConsumableArray(other)));
|
|
820
869
|
}
|
|
821
870
|
}, {
|
|
822
871
|
key: "minabs",
|
|
823
|
-
value: function minabs(
|
|
824
|
-
var
|
|
825
|
-
|
|
872
|
+
value: function minabs() {
|
|
873
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
874
|
+
args[_key5] = arguments[_key5];
|
|
875
|
+
}
|
|
876
|
+
var other = args.map(function (x) {
|
|
877
|
+
return new PowiainaNum(x).abs();
|
|
878
|
+
});
|
|
879
|
+
return PowiainaNum.min.apply(PowiainaNum, [this.abs()].concat(_toConsumableArray(other)));
|
|
826
880
|
}
|
|
827
881
|
}, {
|
|
828
882
|
key: "cmpabs",
|
|
@@ -1118,7 +1172,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1118
1172
|
this.setOperator(Math.pow(10, this.getOperator(0)), 0);
|
|
1119
1173
|
renormalize = true;
|
|
1120
1174
|
}
|
|
1121
|
-
if (this.getOperator(0) > MSI) {
|
|
1175
|
+
if (this.getOperator(0) > MSI && !isFinite(this.getOperator(0))) {
|
|
1122
1176
|
this.setOperator(this.getOperator(1) + 1, 1);
|
|
1123
1177
|
this.setOperator(Math.log10(this.getOperator(0)), 0);
|
|
1124
1178
|
renormalize = true;
|
|
@@ -1303,7 +1357,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1303
1357
|
key: "arr01",
|
|
1304
1358
|
get:
|
|
1305
1359
|
/**
|
|
1306
|
-
* A property
|
|
1360
|
+
* A property array value for version 0.1.x PowiainaNum.
|
|
1307
1361
|
*/
|
|
1308
1362
|
function get() {
|
|
1309
1363
|
var res = [0];
|
|
@@ -1437,6 +1491,64 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1437
1491
|
// 2--3, 1e10-<e1e10, 10^10^10^0->1
|
|
1438
1492
|
return PowiainaNum.NaN.clone();*/
|
|
1439
1493
|
}
|
|
1494
|
+
}, {
|
|
1495
|
+
key: "max",
|
|
1496
|
+
value: function max() {
|
|
1497
|
+
var max = PowiainaNum.NEGATIVE_INFINITY;
|
|
1498
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
1499
|
+
args[_key6] = arguments[_key6];
|
|
1500
|
+
}
|
|
1501
|
+
for (var i = 0; i < args.length; i++) {
|
|
1502
|
+
if (max.lt(args[i])) {
|
|
1503
|
+
max = new PowiainaNum(args[i]).clone();
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
return max;
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Select the smallest number of arguments.
|
|
1510
|
+
*/
|
|
1511
|
+
}, {
|
|
1512
|
+
key: "min",
|
|
1513
|
+
value: function min() {
|
|
1514
|
+
var max = PowiainaNum.POSITIVE_INFINITY;
|
|
1515
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
1516
|
+
args[_key7] = arguments[_key7];
|
|
1517
|
+
}
|
|
1518
|
+
for (var i = 0; i < args.length; i++) {
|
|
1519
|
+
if (max.gt(args[i])) {
|
|
1520
|
+
max = new PowiainaNum(args[i]).clone();
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
return max;
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Restrict a number be not lower than a number
|
|
1527
|
+
*
|
|
1528
|
+
* It's also an alias of `PowiainaNum.max`.
|
|
1529
|
+
* @returns restricted number
|
|
1530
|
+
*/
|
|
1531
|
+
}, {
|
|
1532
|
+
key: "clampMin",
|
|
1533
|
+
value: function clampMin() {
|
|
1534
|
+
return PowiainaNum.max.apply(PowiainaNum, arguments);
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Restrict a number be not higher than a number
|
|
1538
|
+
*
|
|
1539
|
+
* It's also an alias of `PowiainaNum.min`.
|
|
1540
|
+
* @returns restricted number
|
|
1541
|
+
*/
|
|
1542
|
+
}, {
|
|
1543
|
+
key: "clampMax",
|
|
1544
|
+
value: function clampMax() {
|
|
1545
|
+
return PowiainaNum.min.apply(PowiainaNum, arguments);
|
|
1546
|
+
}
|
|
1547
|
+
}, {
|
|
1548
|
+
key: "sign",
|
|
1549
|
+
value: function sign(a) {
|
|
1550
|
+
return new PowiainaNum(a).sign;
|
|
1551
|
+
}
|
|
1440
1552
|
}, {
|
|
1441
1553
|
key: "isNaN",
|
|
1442
1554
|
value: function isNaN(x) {
|
|
@@ -1704,6 +1816,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1704
1816
|
}
|
|
1705
1817
|
}]);
|
|
1706
1818
|
}();
|
|
1819
|
+
/**
|
|
1820
|
+
* Zero
|
|
1821
|
+
*/
|
|
1707
1822
|
PowiainaNum.ZERO = new PowiainaNum({
|
|
1708
1823
|
array: [{
|
|
1709
1824
|
arrow: 0,
|
|
@@ -1715,6 +1830,9 @@ PowiainaNum.ZERO = new PowiainaNum({
|
|
|
1715
1830
|
layer: 0,
|
|
1716
1831
|
sign: 0
|
|
1717
1832
|
});
|
|
1833
|
+
/**
|
|
1834
|
+
* One
|
|
1835
|
+
*/
|
|
1718
1836
|
PowiainaNum.ONE = new PowiainaNum({
|
|
1719
1837
|
array: [{
|
|
1720
1838
|
arrow: 0,
|
|
@@ -1726,12 +1844,22 @@ PowiainaNum.ONE = new PowiainaNum({
|
|
|
1726
1844
|
layer: 0,
|
|
1727
1845
|
sign: 1
|
|
1728
1846
|
});
|
|
1847
|
+
/**
|
|
1848
|
+
* The value of the largest integer n such that n and n + 1 are both
|
|
1849
|
+
* exactly representable as a Number value = 9007199254740991 = 2^53 − 1.
|
|
1850
|
+
*/
|
|
1729
1851
|
PowiainaNum.MSI = new PowiainaNum(MSI);
|
|
1852
|
+
/**
|
|
1853
|
+
* MSI's reciprocate value, = 1/9007199254740991.
|
|
1854
|
+
*/
|
|
1730
1855
|
PowiainaNum.MSI_REC = function () {
|
|
1731
1856
|
var obj = new PowiainaNum(MSI);
|
|
1732
1857
|
obj.small = true;
|
|
1733
1858
|
return obj;
|
|
1734
1859
|
}();
|
|
1860
|
+
/**
|
|
1861
|
+
* 10^(MSI) = 10^9007199254740991.
|
|
1862
|
+
*/
|
|
1735
1863
|
PowiainaNum.E_MSI = new PowiainaNum({
|
|
1736
1864
|
array: [{
|
|
1737
1865
|
arrow: 0,
|
|
@@ -1748,6 +1876,9 @@ PowiainaNum.E_MSI = new PowiainaNum({
|
|
|
1748
1876
|
layer: 0,
|
|
1749
1877
|
sign: 1
|
|
1750
1878
|
});
|
|
1879
|
+
/**
|
|
1880
|
+
* 10^(MSI) 's reciprocate value, = 10^-9007199254740991.
|
|
1881
|
+
*/
|
|
1751
1882
|
PowiainaNum.E_MSI_REC = new PowiainaNum({
|
|
1752
1883
|
array: [{
|
|
1753
1884
|
arrow: 0,
|
|
@@ -1764,51 +1895,69 @@ PowiainaNum.E_MSI_REC = new PowiainaNum({
|
|
|
1764
1895
|
layer: 0,
|
|
1765
1896
|
sign: 1
|
|
1766
1897
|
});
|
|
1898
|
+
/**
|
|
1899
|
+
* Tetrated MSI, = 10↑↑9007199254740991.
|
|
1900
|
+
*/
|
|
1767
1901
|
PowiainaNum.TETRATED_MSI = new PowiainaNum({
|
|
1768
1902
|
array: [{
|
|
1769
1903
|
arrow: 0,
|
|
1770
1904
|
expans: 1,
|
|
1771
1905
|
megota: 1,
|
|
1772
|
-
repeat:
|
|
1906
|
+
repeat: 1e10
|
|
1773
1907
|
}, {
|
|
1774
1908
|
arrow: 1,
|
|
1775
1909
|
expans: 1,
|
|
1776
1910
|
megota: 1,
|
|
1777
|
-
repeat: MSI
|
|
1911
|
+
repeat: MSI - 2
|
|
1778
1912
|
}],
|
|
1779
1913
|
small: false,
|
|
1780
1914
|
layer: 0,
|
|
1781
1915
|
sign: 1
|
|
1782
1916
|
});
|
|
1917
|
+
/**
|
|
1918
|
+
* Pentated MSI, = 10↑↑↑9007199254740991.
|
|
1919
|
+
*/
|
|
1783
1920
|
PowiainaNum.PENTATED_MSI = new PowiainaNum({
|
|
1784
1921
|
array: [{
|
|
1785
1922
|
arrow: 0,
|
|
1786
1923
|
expans: 1,
|
|
1787
1924
|
megota: 1,
|
|
1788
|
-
repeat:
|
|
1789
|
-
}, {
|
|
1790
|
-
arrow: 1,
|
|
1791
|
-
expans: 1,
|
|
1792
|
-
megota: 1,
|
|
1793
|
-
repeat: MSI
|
|
1925
|
+
repeat: 10
|
|
1794
1926
|
}, {
|
|
1795
1927
|
arrow: 2,
|
|
1796
1928
|
expans: 1,
|
|
1797
1929
|
megota: 1,
|
|
1798
|
-
repeat: MSI
|
|
1930
|
+
repeat: MSI - 1
|
|
1799
1931
|
}],
|
|
1800
1932
|
small: false,
|
|
1801
1933
|
layer: 0,
|
|
1802
1934
|
sign: 1
|
|
1803
1935
|
});
|
|
1936
|
+
/**
|
|
1937
|
+
* Tritri, = 3↑↑↑3 = power tower with height 7625597484987 base 3.
|
|
1938
|
+
*/
|
|
1804
1939
|
PowiainaNum.TRITRI = new PowiainaNum({
|
|
1805
1940
|
small: false,
|
|
1806
1941
|
layer: 0,
|
|
1807
1942
|
sign: 1,
|
|
1808
1943
|
array: [newOperator(3638334640023.7783, 0, 1, 1), newOperator(7625587484984, 1, 1, 1)]
|
|
1809
1944
|
});
|
|
1945
|
+
/**
|
|
1946
|
+
* The Graham's Number, = G^64(4)
|
|
1947
|
+
*
|
|
1948
|
+
* = 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{
|
|
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↑↑↑↑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
|
|
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
|
|
1952
|
+
*/
|
|
1810
1953
|
PowiainaNum.GRAHAMS_NUMBER = new PowiainaNum("(10{!})^63 10^^^(10^)^7625597484984 3638334640023.7783");
|
|
1954
|
+
/**
|
|
1955
|
+
* Positive Infinity.
|
|
1956
|
+
*/
|
|
1811
1957
|
PowiainaNum.POSITIVE_INFINITY = new PowiainaNum(Infinity);
|
|
1958
|
+
/**
|
|
1959
|
+
* Negative Infinity.
|
|
1960
|
+
*/
|
|
1812
1961
|
PowiainaNum.NEGATIVE_INFINITY = new PowiainaNum(-Infinity);
|
|
1813
1962
|
PowiainaNum.NaN = new PowiainaNum({
|
|
1814
1963
|
array: [{
|
|
@@ -1821,6 +1970,40 @@ PowiainaNum.NaN = new PowiainaNum({
|
|
|
1821
1970
|
layer: 0,
|
|
1822
1971
|
sign: 0
|
|
1823
1972
|
});
|
|
1973
|
+
/**
|
|
1974
|
+
* The mathematical constant e. This is Euler's number, the base of natural logarithms.
|
|
1975
|
+
*/
|
|
1976
|
+
PowiainaNum.E = new PowiainaNum(Math.E);
|
|
1977
|
+
/**
|
|
1978
|
+
* The natural logarithm of 2 = ln(2).
|
|
1979
|
+
*/
|
|
1980
|
+
PowiainaNum.LN2 = new PowiainaNum(Math.LN2);
|
|
1981
|
+
/**
|
|
1982
|
+
* The natural logarithm of 10.
|
|
1983
|
+
*/
|
|
1984
|
+
PowiainaNum.LN10 = new PowiainaNum(Math.LN10);
|
|
1985
|
+
/**
|
|
1986
|
+
* The base-2 logarithm of e = log_2(e).
|
|
1987
|
+
*/
|
|
1988
|
+
PowiainaNum.LOG2E = new PowiainaNum(Math.LOG2E);
|
|
1989
|
+
/**
|
|
1990
|
+
* The base-10 logarithm of e = log_10(e).
|
|
1991
|
+
*/
|
|
1992
|
+
PowiainaNum.LOG10E = new PowiainaNum(Math.LOG10E);
|
|
1993
|
+
/**
|
|
1994
|
+
* Pi(). This is the ratio of the circumference of a circle to its diameter.
|
|
1995
|
+
*/
|
|
1996
|
+
PowiainaNum.PI = new PowiainaNum(Math.PI);
|
|
1997
|
+
/**
|
|
1998
|
+
* The square root of 0.5, or, equivalently, one divided by the square root of 2.
|
|
1999
|
+
*
|
|
2000
|
+
* = (√2)/2 = √(0.5)
|
|
2001
|
+
*/
|
|
2002
|
+
PowiainaNum.SQRT1_2 = new PowiainaNum(Math.SQRT1_2);
|
|
2003
|
+
/**
|
|
2004
|
+
* The square root of 2 = √2.
|
|
2005
|
+
*/
|
|
2006
|
+
PowiainaNum.SQRT2 = new PowiainaNum(Math.SQRT2);
|
|
1824
2007
|
PowiainaNum.maxOps = 100;
|
|
1825
2008
|
PowiainaNum.arrowFuncMap = new Map();
|
|
1826
2009
|
|