powiaina_num.js 0.2.0-alpha.3.2 → 0.2.0-alpha.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PowiainaNum.cjs.js +72 -10
- package/dist/PowiainaNum.esm.js +72 -10
- package/dist/PowiainaNum.js +72 -10
- package/dist/PowiainaNum.min.js +1 -1
- package/dist/index.d.ts +20 -0
- package/dist/index.js +313 -45
- package/dist/types/index.d.ts +140 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ const MSI_LOG10 = 15.954589770191003;
|
|
|
4
4
|
const MSI_REC = 1.1102230246251568e-16;
|
|
5
5
|
const LONG_STRING_MIN_LENGTH = 17;
|
|
6
6
|
const EXP_E_REC = 1.444667861009766;
|
|
7
|
-
const isPowiainaNum = /^(PN)
|
|
7
|
+
const isPowiainaNum = /^(PN)?[\/\-\+]*(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*\x20*)*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/;
|
|
8
8
|
function newOperator(r, a = 0, e = 1, m = 1) {
|
|
9
9
|
return {
|
|
10
10
|
repeat: r,
|
|
@@ -175,6 +175,12 @@ function countLeadingZerosAfterDecimal(numStr) {
|
|
|
175
175
|
const match = numStr.match(/^0\.(0*)[1-9]/);
|
|
176
176
|
return match ? match[1].length : 0;
|
|
177
177
|
}
|
|
178
|
+
/*
|
|
179
|
+
function countLeadingZerosAfterDecimal(numStr) {
|
|
180
|
+
const match = numStr.match(/^0\.(0*)[1-9]/);
|
|
181
|
+
return match ? match[1].length : 0;
|
|
182
|
+
}
|
|
183
|
+
*/
|
|
178
184
|
//from https://github.com/scipy/scipy/blob/8dba340293fe20e62e173bdf2c10ae208286692f/scipy/special/lambertw.pxd
|
|
179
185
|
// The evaluation can become inaccurate very close to the branch point
|
|
180
186
|
// at ``-1/e``. In some corner cases, `lambertw` might currently
|
|
@@ -217,6 +223,10 @@ function d_lambertw(z, t = 1e-10, pr = true) {
|
|
|
217
223
|
throw Error("Iteration failed to converge: ".concat(z.toString())); //return Decimal.dNaN;
|
|
218
224
|
}
|
|
219
225
|
class PowiainaNum {
|
|
226
|
+
/**
|
|
227
|
+
* Constructor of PowiainaNum class,
|
|
228
|
+
* If no arguments, return `PowiainaNum.NaN`.
|
|
229
|
+
*/
|
|
220
230
|
constructor(arg1) {
|
|
221
231
|
this.array = [{ arrow: 0, expans: 1, megota: 1, repeat: NaN }];
|
|
222
232
|
this.small = false;
|
|
@@ -274,6 +284,10 @@ class PowiainaNum {
|
|
|
274
284
|
return a.eq(b);
|
|
275
285
|
})())
|
|
276
286
|
return PowiainaNum.ZERO.clone();
|
|
287
|
+
// Run pure number calculates in there
|
|
288
|
+
if (x.abs().lt(MSI) && y.abs().lt(MSI)) {
|
|
289
|
+
return PowiainaNum.fromNumber(x.toNumber() + y.toNumber());
|
|
290
|
+
}
|
|
277
291
|
// calculate anything > e9e15 or <e-9e15, take absval bigger.
|
|
278
292
|
if (x.abs().lt(PowiainaNum.E_MSI_REC) ||
|
|
279
293
|
x.abs().gt(PowiainaNum.E_MSI) ||
|
|
@@ -389,6 +403,9 @@ class PowiainaNum {
|
|
|
389
403
|
static div(t, other) {
|
|
390
404
|
return new PowiainaNum(t).div(other);
|
|
391
405
|
}
|
|
406
|
+
/**
|
|
407
|
+
* @returns 10 to the power of `this`
|
|
408
|
+
*/
|
|
392
409
|
pow10() {
|
|
393
410
|
var _a, _b;
|
|
394
411
|
const r = this.clone();
|
|
@@ -408,6 +425,8 @@ class PowiainaNum {
|
|
|
408
425
|
return PowiainaNum.ONE;
|
|
409
426
|
return new PowiainaNum(Math.pow(10, (Math.pow(r.array[0].repeat, -1))));
|
|
410
427
|
}
|
|
428
|
+
if (r.gt(PowiainaNum.TETRATED_MSI))
|
|
429
|
+
return r;
|
|
411
430
|
r.setOperator(((_b = (_a = r.array[1]) === null || _a === void 0 ? void 0 : _a.repeat) !== null && _b !== void 0 ? _b : 0) + 1, 1);
|
|
412
431
|
r.normalize();
|
|
413
432
|
return r;
|
|
@@ -463,7 +482,7 @@ class PowiainaNum {
|
|
|
463
482
|
return new PowiainaNum(t).sqrt();
|
|
464
483
|
}
|
|
465
484
|
cbrt() {
|
|
466
|
-
return this.root(3);
|
|
485
|
+
return this.abs().root(3).mul(this.sign);
|
|
467
486
|
}
|
|
468
487
|
static cbrt(t) {
|
|
469
488
|
return new PowiainaNum(t).cbrt();
|
|
@@ -600,13 +619,21 @@ class PowiainaNum {
|
|
|
600
619
|
r += l;
|
|
601
620
|
x.setOperator(x.getOperator(1) - l, 1);
|
|
602
621
|
}
|
|
603
|
-
for (
|
|
604
|
-
if (x.
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
622
|
+
for (var i = 0; i < 100; ++i) {
|
|
623
|
+
if (x.lt(PowiainaNum.ZERO)) {
|
|
624
|
+
x = PowiainaNum.pow(base, x);
|
|
625
|
+
--r;
|
|
626
|
+
}
|
|
627
|
+
else if (x.lte(1)) {
|
|
628
|
+
return new PowiainaNum(r + x.toNumber() - 1);
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
++r;
|
|
632
|
+
x = PowiainaNum.log(x, base);
|
|
633
|
+
}
|
|
608
634
|
}
|
|
609
|
-
|
|
635
|
+
if (x.gt(10))
|
|
636
|
+
return new PowiainaNum(r);
|
|
610
637
|
return PowiainaNum.NaN.clone();
|
|
611
638
|
}
|
|
612
639
|
static tetrate(t, other2, payload = 1) {
|
|
@@ -630,6 +657,8 @@ class PowiainaNum {
|
|
|
630
657
|
}
|
|
631
658
|
if (this.array.length == 1)
|
|
632
659
|
return new PowiainaNum(Math.log10(this.array[0].repeat));
|
|
660
|
+
if (this.gte(PowiainaNum.TETRATED_MSI))
|
|
661
|
+
return this.clone();
|
|
633
662
|
let x = this.clone();
|
|
634
663
|
x.array[1].repeat = x.array[1].repeat - 1;
|
|
635
664
|
x.normalize();
|
|
@@ -649,6 +678,38 @@ class PowiainaNum {
|
|
|
649
678
|
ln() {
|
|
650
679
|
return this.log();
|
|
651
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* plog10, beware unexpected errors.
|
|
683
|
+
*/
|
|
684
|
+
plog10() {
|
|
685
|
+
return this.max(1).log10();
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* plog10, beware unexpected errors.
|
|
689
|
+
*/
|
|
690
|
+
static plog10(t) {
|
|
691
|
+
return new PowiainaNum(t).plog10();
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* plog, beware unexpected errors.
|
|
695
|
+
*/
|
|
696
|
+
plog(base = Math.E) {
|
|
697
|
+
// log_a b = log_x b / log_x a;
|
|
698
|
+
const other = new PowiainaNum(base);
|
|
699
|
+
return this.plog10().div(other.plog10());
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* plog, beware unexpected errors.
|
|
703
|
+
*/
|
|
704
|
+
static plog(t, base = Math.E) {
|
|
705
|
+
return new PowiainaNum(t).plog(base);
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* pln, beware unexpected errors.
|
|
709
|
+
*/
|
|
710
|
+
pln() {
|
|
711
|
+
return this.plog();
|
|
712
|
+
}
|
|
652
713
|
static exp(x) {
|
|
653
714
|
let y = new PowiainaNum(x);
|
|
654
715
|
return y.pow_base(Math.E);
|
|
@@ -757,7 +818,7 @@ class PowiainaNum {
|
|
|
757
818
|
else if (this.small) {
|
|
758
819
|
return PowiainaNum.fromNumber(f_lambertw(this.toNumber()));
|
|
759
820
|
}
|
|
760
|
-
else if (this.
|
|
821
|
+
else if (this.lt(MSI)) {
|
|
761
822
|
return PowiainaNum.fromNumber(f_lambertw(this.sign * this.getOperator(0)));
|
|
762
823
|
}
|
|
763
824
|
else if (this.lt("eee15")) {
|
|
@@ -821,21 +882,160 @@ class PowiainaNum {
|
|
|
821
882
|
// 2--3, 1e10-<e1e10, 10^10^10^0->1
|
|
822
883
|
return PowiainaNum.NaN.clone();*/
|
|
823
884
|
}
|
|
824
|
-
|
|
825
|
-
const
|
|
826
|
-
|
|
885
|
+
arrow(arrows2) {
|
|
886
|
+
const t = this.clone();
|
|
887
|
+
const arrows = new PowiainaNum(arrows2);
|
|
888
|
+
if (!arrows.isInt() || arrows.lt(PowiainaNum.ZERO)) {
|
|
889
|
+
console.warn("The arrow is <0 or not a integer, the returned function will return NaN.");
|
|
890
|
+
return function () { return PowiainaNum.NaN.clone(); };
|
|
891
|
+
}
|
|
892
|
+
if (arrows.eq(0))
|
|
893
|
+
return function (other) { return t.mul(other); };
|
|
894
|
+
if (arrows.eq(1))
|
|
895
|
+
return function (other) { return t.pow(other); };
|
|
896
|
+
if (arrows.eq(2))
|
|
897
|
+
return function (other) { return t.tetrate(other); };
|
|
898
|
+
return function (other2, depth = 0) {
|
|
899
|
+
const other = new PowiainaNum(other2);
|
|
900
|
+
let ctt = PowiainaNum.arrowFuncMap.get(`${t.toString()} ${arrows.toString()} ${other.toString()}`);
|
|
901
|
+
if (ctt)
|
|
902
|
+
return ctt.clone();
|
|
903
|
+
let res = (function () {
|
|
904
|
+
let r;
|
|
905
|
+
if (t.isNaN() || other.isNaN())
|
|
906
|
+
return PowiainaNum.NaN.clone();
|
|
907
|
+
if (other.lt(PowiainaNum.ZERO))
|
|
908
|
+
return PowiainaNum.NaN.clone();
|
|
909
|
+
if (t.eq(PowiainaNum.ZERO)) {
|
|
910
|
+
if (other.eq(PowiainaNum.ONE))
|
|
911
|
+
return PowiainaNum.ZERO.clone();
|
|
912
|
+
return PowiainaNum.NaN.clone();
|
|
913
|
+
}
|
|
914
|
+
if (t.eq(PowiainaNum.ONE))
|
|
915
|
+
return PowiainaNum.ONE.clone();
|
|
916
|
+
if (other.eq(PowiainaNum.ZERO))
|
|
917
|
+
return PowiainaNum.ONE.clone();
|
|
918
|
+
if (other.eq(PowiainaNum.ONE))
|
|
919
|
+
return t.clone();
|
|
920
|
+
// arrow > 9e15, that using 10{x}, x=arrow;
|
|
921
|
+
if (arrows.gt(PowiainaNum.MSI)) {
|
|
922
|
+
r = arrows.clone();
|
|
923
|
+
r.setOperator(r.getOperator(Infinity) + 1, Infinity);
|
|
924
|
+
return r;
|
|
925
|
+
}
|
|
926
|
+
let arrowsNum = arrows.toNumber();
|
|
927
|
+
// arrow < 9e15
|
|
928
|
+
// 10{x}2 = 10{x-1}10
|
|
929
|
+
if (other.eq(2))
|
|
930
|
+
return t.arrow(arrowsNum - 1)(t, depth + 1);
|
|
931
|
+
if (t.max(other).gt(PowiainaNum.arrowMSI(arrowsNum + 1)))
|
|
932
|
+
return t.max(other);
|
|
933
|
+
if (t.gt(PowiainaNum.arrowMSI(arrowsNum)) || other.gt(MSI)) {
|
|
934
|
+
if (t.gt(PowiainaNum.arrowMSI(arrowsNum))) {
|
|
935
|
+
r = t.clone();
|
|
936
|
+
r.setOperator(r.getOperator(arrowsNum) - 1, arrowsNum);
|
|
937
|
+
r.normalize();
|
|
938
|
+
}
|
|
939
|
+
else if (t.gt(PowiainaNum.arrowMSI(arrowsNum - 1))) {
|
|
940
|
+
r = new PowiainaNum(t.getOperator(arrowsNum - 1));
|
|
941
|
+
}
|
|
942
|
+
else {
|
|
943
|
+
r = PowiainaNum.ZERO;
|
|
944
|
+
}
|
|
945
|
+
var j = r.add(other);
|
|
946
|
+
j.setOperator(j.getOperator(arrowsNum) + 1, arrowsNum);
|
|
947
|
+
j.normalize();
|
|
948
|
+
return j;
|
|
949
|
+
}
|
|
950
|
+
if (depth >= PowiainaNum.maxOps + 10) {
|
|
951
|
+
return new PowiainaNum([[0, 10], [arrowsNum, 1]]);
|
|
952
|
+
}
|
|
953
|
+
const y = other.toNumber();
|
|
954
|
+
let f = Math.floor(y);
|
|
955
|
+
const arrows_m1 = arrows.sub(PowiainaNum.ONE);
|
|
956
|
+
r = t.arrow(arrows_m1)(y - f, depth + 1);
|
|
957
|
+
let i = 0;
|
|
958
|
+
for (let m = PowiainaNum.arrowMSI(arrowsNum - 1); f !== 0 && r.lt(m) && i < 100; i++) {
|
|
959
|
+
if (f > 0) {
|
|
960
|
+
r = t.arrow(arrows_m1)(r, depth + 1);
|
|
961
|
+
--f;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
if (i == 100)
|
|
965
|
+
f = 0;
|
|
966
|
+
r.setOperator(r.getOperator(arrowsNum - 1) + f, arrowsNum - 1);
|
|
967
|
+
r.normalize();
|
|
968
|
+
return r;
|
|
969
|
+
})();
|
|
970
|
+
if (depth < PowiainaNum.maxOps + 10) {
|
|
971
|
+
PowiainaNum.arrowFuncMap.set(`${t.toString()} ${arrows.toString()} ${other.toString()}`, res.clone());
|
|
972
|
+
}
|
|
973
|
+
return res;
|
|
974
|
+
};
|
|
827
975
|
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
return this.gte(other) ? other.clone() : this.clone();
|
|
976
|
+
chain(other, arrows) {
|
|
977
|
+
return this.arrow(arrows)(other);
|
|
831
978
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
979
|
+
/**
|
|
980
|
+
* Select the largest number of arguments.
|
|
981
|
+
*/
|
|
982
|
+
static max(...args) {
|
|
983
|
+
let max = PowiainaNum.NEGATIVE_INFINITY;
|
|
984
|
+
for (let i = 0; i < args.length; i++) {
|
|
985
|
+
if (max.lt(args[i])) {
|
|
986
|
+
max = new PowiainaNum(args[i]).clone();
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
return max;
|
|
835
990
|
}
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
991
|
+
/**
|
|
992
|
+
* Select the smallest number of arguments.
|
|
993
|
+
*/
|
|
994
|
+
static min(...args) {
|
|
995
|
+
let max = PowiainaNum.POSITIVE_INFINITY;
|
|
996
|
+
for (let i = 0; i < args.length; i++) {
|
|
997
|
+
if (max.gt(args[i])) {
|
|
998
|
+
max = new PowiainaNum(args[i]).clone();
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
return max;
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Restrict a number be not lower than a number
|
|
1005
|
+
*
|
|
1006
|
+
* It's also an alias of `PowiainaNum.max`.
|
|
1007
|
+
* @returns restricted number
|
|
1008
|
+
*/
|
|
1009
|
+
static clampMin(...args) {
|
|
1010
|
+
return PowiainaNum.max(...args);
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Restrict a number be not higher than a number
|
|
1014
|
+
*
|
|
1015
|
+
* It's also an alias of `PowiainaNum.min`.
|
|
1016
|
+
* @returns restricted number
|
|
1017
|
+
*/
|
|
1018
|
+
static clampMax(...args) {
|
|
1019
|
+
return PowiainaNum.min(...args);
|
|
1020
|
+
}
|
|
1021
|
+
max(...args) {
|
|
1022
|
+
return PowiainaNum.max(this, ...args);
|
|
1023
|
+
}
|
|
1024
|
+
min(...args) {
|
|
1025
|
+
return PowiainaNum.min(this, ...args);
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Compare what PowiainaNum's absolute value is max
|
|
1029
|
+
* @param args
|
|
1030
|
+
* @returns absolute value max number's absolute value
|
|
1031
|
+
*/
|
|
1032
|
+
maxabs(...args) {
|
|
1033
|
+
const other = args.map((x) => new PowiainaNum(x).abs());
|
|
1034
|
+
return PowiainaNum.max(this.abs(), ...other);
|
|
1035
|
+
}
|
|
1036
|
+
minabs(...args) {
|
|
1037
|
+
const other = args.map((x) => new PowiainaNum(x).abs());
|
|
1038
|
+
return PowiainaNum.min(this.abs(), ...other);
|
|
839
1039
|
}
|
|
840
1040
|
cmpabs(x) {
|
|
841
1041
|
const other = new PowiainaNum(x).abs();
|
|
@@ -977,6 +1177,9 @@ class PowiainaNum {
|
|
|
977
1177
|
let t = this.cmp(other);
|
|
978
1178
|
return t == 0 || t == 1;
|
|
979
1179
|
}
|
|
1180
|
+
static sign(a) {
|
|
1181
|
+
return new PowiainaNum(a).sign;
|
|
1182
|
+
}
|
|
980
1183
|
isNaN() {
|
|
981
1184
|
return isNaN(this.getOperator(0));
|
|
982
1185
|
}
|
|
@@ -1111,7 +1314,7 @@ class PowiainaNum {
|
|
|
1111
1314
|
this.setOperator(Math.pow(10, this.getOperator(0)), 0);
|
|
1112
1315
|
renormalize = true;
|
|
1113
1316
|
}
|
|
1114
|
-
if (this.getOperator(0) > MSI) {
|
|
1317
|
+
if (this.getOperator(0) > MSI && !isFinite(this.getOperator(0))) {
|
|
1115
1318
|
this.setOperator(this.getOperator(1) + 1, 1);
|
|
1116
1319
|
this.setOperator(Math.log10(this.getOperator(0)), 0);
|
|
1117
1320
|
renormalize = true;
|
|
@@ -1159,6 +1362,9 @@ class PowiainaNum {
|
|
|
1159
1362
|
} while (renormalize);
|
|
1160
1363
|
return this;
|
|
1161
1364
|
}
|
|
1365
|
+
static arrowMSI(arrowsNum) {
|
|
1366
|
+
return new PowiainaNum(`10${arrowsNum}${MSI}`);
|
|
1367
|
+
}
|
|
1162
1368
|
/**
|
|
1163
1369
|
* @returns number will return the index of the operator in array. return as x.5 if it's between the xth and x+1th operators.
|
|
1164
1370
|
*/
|
|
@@ -1349,23 +1555,12 @@ class PowiainaNum {
|
|
|
1349
1555
|
a = true;
|
|
1350
1556
|
}
|
|
1351
1557
|
if (!a) {
|
|
1352
|
-
/**
|
|
1353
|
-
* Possible forms:
|
|
1354
|
-
* 1.33e-114514
|
|
1355
|
-
* 0.000000114514e-114514
|
|
1356
|
-
* 0.00....00114514e-1919810
|
|
1357
|
-
*
|
|
1358
|
-
* 0.0000000...0000000114514
|
|
1359
|
-
* 100000.....000000e-1919810
|
|
1360
|
-
* TODO: 1.0000e-1000000....00000
|
|
1361
|
-
*/
|
|
1362
1558
|
let m = input.search(/e/);
|
|
1363
|
-
let exponent = input.substring((m == -
|
|
1364
|
-
let mantissa = input.substring(0, m == -
|
|
1559
|
+
let exponent = input.substring((m == -1 ? input.length : m) + 1);
|
|
1560
|
+
let mantissa = input.substring(0, m == -1 ? undefined : m);
|
|
1365
1561
|
let mantissaME = [0, 0];
|
|
1366
1562
|
// Handle mantissa to ME
|
|
1367
1563
|
mantissaME[1] = Number(exponent ? exponent : "0");
|
|
1368
|
-
console.log(mantissa);
|
|
1369
1564
|
// Is regular number gte 1:
|
|
1370
1565
|
if (Number(mantissa) >= 1) {
|
|
1371
1566
|
// check The mantissa is very long?
|
|
@@ -1374,14 +1569,12 @@ class PowiainaNum {
|
|
|
1374
1569
|
let log10float = log10mant - log10int;
|
|
1375
1570
|
mantissaME[0] = Math.pow(10, log10float);
|
|
1376
1571
|
mantissaME[1] += log10float;
|
|
1377
|
-
console.log(mantissaME);
|
|
1378
1572
|
}
|
|
1379
1573
|
else {
|
|
1380
1574
|
// If not , count how many zeros until reached non-zero numbers
|
|
1381
1575
|
let zeros = countLeadingZerosAfterDecimal(mantissa);
|
|
1382
1576
|
mantissa = mantissa.substring(mantissa.search(/[1-9]/));
|
|
1383
|
-
|
|
1384
|
-
mantissa = mantissa[0].charAt(0) + "." + mantissa.substring(1);
|
|
1577
|
+
mantissa = mantissa.charAt(0) + "." + mantissa.substring(1);
|
|
1385
1578
|
zeros += 1;
|
|
1386
1579
|
mantissaME[0] = Number(mantissa);
|
|
1387
1580
|
mantissaME[1] += -zeros;
|
|
@@ -1389,7 +1582,6 @@ class PowiainaNum {
|
|
|
1389
1582
|
// We'll get [a, b] which respents a*10^b;
|
|
1390
1583
|
// actually b < 0; So we can ^-1
|
|
1391
1584
|
// /((a*10^b)^-1) = /(a^-1*10^-b) = /(a^-1 * 10 * 10^(-b-1))
|
|
1392
|
-
console.log(mantissaME);
|
|
1393
1585
|
return PowiainaNum.pow(10, -mantissaME[1] - 1).mul(Math.pow(mantissaME[0], -1) * 10).rec();
|
|
1394
1586
|
}
|
|
1395
1587
|
if (isFinite(res) && a) {
|
|
@@ -1623,7 +1815,7 @@ class PowiainaNum {
|
|
|
1623
1815
|
}
|
|
1624
1816
|
}
|
|
1625
1817
|
/**
|
|
1626
|
-
* A property
|
|
1818
|
+
* A property array value for version 0.1.x PowiainaNum.
|
|
1627
1819
|
*/
|
|
1628
1820
|
get arr01() {
|
|
1629
1821
|
let res = [0];
|
|
@@ -1646,6 +1838,9 @@ class PowiainaNum {
|
|
|
1646
1838
|
return res;
|
|
1647
1839
|
}
|
|
1648
1840
|
}
|
|
1841
|
+
/**
|
|
1842
|
+
* Zero
|
|
1843
|
+
*/
|
|
1649
1844
|
PowiainaNum.ZERO = new PowiainaNum({
|
|
1650
1845
|
array: [
|
|
1651
1846
|
{
|
|
@@ -1659,6 +1854,9 @@ PowiainaNum.ZERO = new PowiainaNum({
|
|
|
1659
1854
|
layer: 0,
|
|
1660
1855
|
sign: 0,
|
|
1661
1856
|
});
|
|
1857
|
+
/**
|
|
1858
|
+
* One
|
|
1859
|
+
*/
|
|
1662
1860
|
PowiainaNum.ONE = new PowiainaNum({
|
|
1663
1861
|
array: [
|
|
1664
1862
|
{
|
|
@@ -1672,12 +1870,22 @@ PowiainaNum.ONE = new PowiainaNum({
|
|
|
1672
1870
|
layer: 0,
|
|
1673
1871
|
sign: 1,
|
|
1674
1872
|
});
|
|
1873
|
+
/**
|
|
1874
|
+
* The value of the largest integer n such that n and n + 1 are both
|
|
1875
|
+
* exactly representable as a Number value = 9007199254740991 = 2^53 − 1.
|
|
1876
|
+
*/
|
|
1675
1877
|
PowiainaNum.MSI = new PowiainaNum(MSI);
|
|
1878
|
+
/**
|
|
1879
|
+
* MSI's reciprocate value, = 1/9007199254740991.
|
|
1880
|
+
*/
|
|
1676
1881
|
PowiainaNum.MSI_REC = (function () {
|
|
1677
1882
|
let obj = new PowiainaNum(MSI);
|
|
1678
1883
|
obj.small = true;
|
|
1679
1884
|
return obj;
|
|
1680
1885
|
})();
|
|
1886
|
+
/**
|
|
1887
|
+
* 10^(MSI) = 10^9007199254740991.
|
|
1888
|
+
*/
|
|
1681
1889
|
PowiainaNum.E_MSI = new PowiainaNum({
|
|
1682
1890
|
array: [
|
|
1683
1891
|
{
|
|
@@ -1692,6 +1900,9 @@ PowiainaNum.E_MSI = new PowiainaNum({
|
|
|
1692
1900
|
layer: 0,
|
|
1693
1901
|
sign: 1,
|
|
1694
1902
|
});
|
|
1903
|
+
/**
|
|
1904
|
+
* 10^(MSI) 's reciprocate value, = 10^-9007199254740991.
|
|
1905
|
+
*/
|
|
1695
1906
|
PowiainaNum.E_MSI_REC = new PowiainaNum({
|
|
1696
1907
|
array: [
|
|
1697
1908
|
{
|
|
@@ -1706,35 +1917,43 @@ PowiainaNum.E_MSI_REC = new PowiainaNum({
|
|
|
1706
1917
|
layer: 0,
|
|
1707
1918
|
sign: 1,
|
|
1708
1919
|
});
|
|
1920
|
+
/**
|
|
1921
|
+
* Tetrated MSI, = 10↑↑9007199254740991.
|
|
1922
|
+
*/
|
|
1709
1923
|
PowiainaNum.TETRATED_MSI = new PowiainaNum({
|
|
1710
1924
|
array: [
|
|
1711
1925
|
{
|
|
1712
1926
|
arrow: 0,
|
|
1713
1927
|
expans: 1,
|
|
1714
1928
|
megota: 1,
|
|
1715
|
-
repeat:
|
|
1929
|
+
repeat: 1e10,
|
|
1716
1930
|
},
|
|
1717
|
-
{ arrow: 1, expans: 1, megota: 1, repeat: MSI },
|
|
1931
|
+
{ arrow: 1, expans: 1, megota: 1, repeat: MSI - 2 },
|
|
1718
1932
|
],
|
|
1719
1933
|
small: false,
|
|
1720
1934
|
layer: 0,
|
|
1721
1935
|
sign: 1,
|
|
1722
1936
|
});
|
|
1937
|
+
/**
|
|
1938
|
+
* Pentated MSI, = 10↑↑↑9007199254740991.
|
|
1939
|
+
*/
|
|
1723
1940
|
PowiainaNum.PENTATED_MSI = new PowiainaNum({
|
|
1724
1941
|
array: [
|
|
1725
1942
|
{
|
|
1726
1943
|
arrow: 0,
|
|
1727
1944
|
expans: 1,
|
|
1728
1945
|
megota: 1,
|
|
1729
|
-
repeat:
|
|
1946
|
+
repeat: 10,
|
|
1730
1947
|
},
|
|
1731
|
-
{ arrow:
|
|
1732
|
-
{ arrow: 2, expans: 1, megota: 1, repeat: MSI },
|
|
1948
|
+
{ arrow: 2, expans: 1, megota: 1, repeat: MSI - 1 },
|
|
1733
1949
|
],
|
|
1734
1950
|
small: false,
|
|
1735
1951
|
layer: 0,
|
|
1736
1952
|
sign: 1,
|
|
1737
1953
|
});
|
|
1954
|
+
/**
|
|
1955
|
+
* Tritri, = 3↑↑↑3 = power tower with height 7625597484987 base 3.
|
|
1956
|
+
*/
|
|
1738
1957
|
PowiainaNum.TRITRI = new PowiainaNum({
|
|
1739
1958
|
small: false, layer: 0, sign: 1,
|
|
1740
1959
|
array: [
|
|
@@ -1742,8 +1961,22 @@ PowiainaNum.TRITRI = new PowiainaNum({
|
|
|
1742
1961
|
newOperator(7625587484984, 1, 1, 1)
|
|
1743
1962
|
]
|
|
1744
1963
|
});
|
|
1964
|
+
/**
|
|
1965
|
+
* The Graham's Number, = G^64(4)
|
|
1966
|
+
*
|
|
1967
|
+
* = 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{
|
|
1968
|
+
* 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
|
|
1969
|
+
* }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
|
|
1970
|
+
* }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
|
|
1971
|
+
*/
|
|
1745
1972
|
PowiainaNum.GRAHAMS_NUMBER = new PowiainaNum("(10{!})^63 10^^^(10^)^7625597484984 3638334640023.7783");
|
|
1973
|
+
/**
|
|
1974
|
+
* Positive Infinity.
|
|
1975
|
+
*/
|
|
1746
1976
|
PowiainaNum.POSITIVE_INFINITY = new PowiainaNum(Infinity);
|
|
1977
|
+
/**
|
|
1978
|
+
* Negative Infinity.
|
|
1979
|
+
*/
|
|
1747
1980
|
PowiainaNum.NEGATIVE_INFINITY = new PowiainaNum(-Infinity);
|
|
1748
1981
|
PowiainaNum.NaN = new PowiainaNum({
|
|
1749
1982
|
array: [
|
|
@@ -1758,5 +1991,40 @@ PowiainaNum.NaN = new PowiainaNum({
|
|
|
1758
1991
|
layer: 0,
|
|
1759
1992
|
sign: 0,
|
|
1760
1993
|
});
|
|
1994
|
+
/**
|
|
1995
|
+
* The mathematical constant e. This is Euler's number, the base of natural logarithms.
|
|
1996
|
+
*/
|
|
1997
|
+
PowiainaNum.E = new PowiainaNum(Math.E);
|
|
1998
|
+
/**
|
|
1999
|
+
* The natural logarithm of 2 = ln(2).
|
|
2000
|
+
*/
|
|
2001
|
+
PowiainaNum.LN2 = new PowiainaNum(Math.LN2);
|
|
2002
|
+
/**
|
|
2003
|
+
* The natural logarithm of 10.
|
|
2004
|
+
*/
|
|
2005
|
+
PowiainaNum.LN10 = new PowiainaNum(Math.LN10);
|
|
2006
|
+
/**
|
|
2007
|
+
* The base-2 logarithm of e = log_2(e).
|
|
2008
|
+
*/
|
|
2009
|
+
PowiainaNum.LOG2E = new PowiainaNum(Math.LOG2E);
|
|
2010
|
+
/**
|
|
2011
|
+
* The base-10 logarithm of e = log_10(e).
|
|
2012
|
+
*/
|
|
2013
|
+
PowiainaNum.LOG10E = new PowiainaNum(Math.LOG10E);
|
|
2014
|
+
/**
|
|
2015
|
+
* Pi(). This is the ratio of the circumference of a circle to its diameter.
|
|
2016
|
+
*/
|
|
2017
|
+
PowiainaNum.PI = new PowiainaNum(Math.PI);
|
|
2018
|
+
/**
|
|
2019
|
+
* The square root of 0.5, or, equivalently, one divided by the square root of 2.
|
|
2020
|
+
*
|
|
2021
|
+
* = (√2)/2 = √(0.5)
|
|
2022
|
+
*/
|
|
2023
|
+
PowiainaNum.SQRT1_2 = new PowiainaNum(Math.SQRT1_2);
|
|
2024
|
+
/**
|
|
2025
|
+
* The square root of 2 = √2.
|
|
2026
|
+
*/
|
|
2027
|
+
PowiainaNum.SQRT2 = new PowiainaNum(Math.SQRT2);
|
|
1761
2028
|
PowiainaNum.maxOps = 100;
|
|
2029
|
+
PowiainaNum.arrowFuncMap = new Map();
|
|
1762
2030
|
export default PowiainaNum;
|