powiaina_num.js 0.2.27 → 0.2.29
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 +190 -182
- package/dist/PowiainaNum.esm.js +190 -182
- package/dist/PowiainaNum.js +190 -182
- package/dist/PowiainaNum.min.js +1 -1
- package/package.json +1 -1
package/dist/PowiainaNum.cjs.js
CHANGED
|
@@ -362,7 +362,7 @@ function d_lambertw(z) {
|
|
|
362
362
|
if (z.eq(PowiainaNum.ONE)) return new PowiainaNum(OMEGA);
|
|
363
363
|
w = PowiainaNum.log(z);
|
|
364
364
|
} else {
|
|
365
|
-
if (z.eq(PowiainaNum.ZERO)) return PowiainaNum.NEGATIVE_INFINITY
|
|
365
|
+
if (z.eq(PowiainaNum.ZERO)) return PowiainaNum.NEGATIVE_INFINITY;
|
|
366
366
|
w = PowiainaNum.log(z.neg());
|
|
367
367
|
}
|
|
368
368
|
for (var i = 0; i < 100; ++i) {
|
|
@@ -385,9 +385,11 @@ function arraySortFunction(a, b) {
|
|
|
385
385
|
*/
|
|
386
386
|
function mergeSameArrays(x) {
|
|
387
387
|
for (var i = 1; i < x.array.length - 1; ++i) {
|
|
388
|
-
|
|
388
|
+
var q = x.array[i];
|
|
389
|
+
var r = x.array[i + 1];
|
|
390
|
+
if (q.arrow == r.arrow && q.expans == r.expans && q.megota == r.megota) {
|
|
389
391
|
// same array's merge
|
|
390
|
-
|
|
392
|
+
q.repeat += r.repeat;
|
|
391
393
|
x.array.splice(i + 1, 1);
|
|
392
394
|
--i;
|
|
393
395
|
}
|
|
@@ -410,7 +412,7 @@ function arrowpsdInv(base, height, res4) {
|
|
|
410
412
|
var add2handled = arrowpsdInv(x, y.add(1), z);
|
|
411
413
|
var handled = add2handled.sub(2);
|
|
412
414
|
var bottom = arrowpsdInv(x, y, x);
|
|
413
|
-
var top = x
|
|
415
|
+
var top = x;
|
|
414
416
|
var anylog2 = handled.pow_base(top.div(bottom)).mul(bottom);
|
|
415
417
|
return arrowpsd(x, y, anylog2);
|
|
416
418
|
}
|
|
@@ -424,7 +426,7 @@ function arrowpsd(base, height, other) {
|
|
|
424
426
|
if (z.gt(x)) {
|
|
425
427
|
var anylog2 = arrowpsdInv(x, y, z);
|
|
426
428
|
var bottom = arrowpsdInv(x, y, x);
|
|
427
|
-
var top = x
|
|
429
|
+
var top = x;
|
|
428
430
|
var handled = anylog2.div(bottom).logBase(top.div(bottom));
|
|
429
431
|
return arrowpsd(x, y.add(1), PowiainaNum.add(2, handled));
|
|
430
432
|
}
|
|
@@ -443,6 +445,20 @@ function log10PosBigInt(input) {
|
|
|
443
445
|
return Math.log10(Number(firstbits)) + Math.LOG10E / Math.LOG2E * Number(cutbits);
|
|
444
446
|
}
|
|
445
447
|
//#endregion
|
|
448
|
+
var arrays = {
|
|
449
|
+
ZERO: [{
|
|
450
|
+
arrow: 0,
|
|
451
|
+
expans: 1,
|
|
452
|
+
megota: 1,
|
|
453
|
+
repeat: Infinity
|
|
454
|
+
}],
|
|
455
|
+
NaN: [{
|
|
456
|
+
arrow: 0,
|
|
457
|
+
expans: 1,
|
|
458
|
+
megota: 1,
|
|
459
|
+
repeat: NaN
|
|
460
|
+
}]
|
|
461
|
+
};
|
|
446
462
|
var PowiainaNum = /*#__PURE__*/function () {
|
|
447
463
|
/**
|
|
448
464
|
* Constructor of PowiainaNum class,
|
|
@@ -450,22 +466,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
450
466
|
*/
|
|
451
467
|
function PowiainaNum(arg1) {
|
|
452
468
|
_classCallCheck(this, PowiainaNum);
|
|
453
|
-
this.array =
|
|
454
|
-
arrow: 0,
|
|
455
|
-
expans: 1,
|
|
456
|
-
megota: 1,
|
|
457
|
-
repeat: NaN
|
|
458
|
-
}];
|
|
469
|
+
this.array = arrays.NaN;
|
|
459
470
|
this.small = false;
|
|
460
471
|
this.sign = 0;
|
|
461
472
|
this.layer = 0;
|
|
462
473
|
if (PowiainaNum.blankArgumentConstructorReturnZero) {
|
|
463
|
-
this.array =
|
|
464
|
-
arrow: 0,
|
|
465
|
-
expans: 1,
|
|
466
|
-
megota: 1,
|
|
467
|
-
repeat: Infinity
|
|
468
|
-
}];
|
|
474
|
+
this.array = arrays.ZERO;
|
|
469
475
|
this.small = true;
|
|
470
476
|
}
|
|
471
477
|
if (arg1 !== undefined) {
|
|
@@ -473,11 +479,11 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
473
479
|
if (typeof arg1 == "undefined") {} else if (typeof arg1 == "number") {
|
|
474
480
|
var obj = PowiainaNum.fromNumber(arg1);
|
|
475
481
|
this.resetFromObject(obj);
|
|
476
|
-
} else if (_typeof(arg1) == "object") {
|
|
477
|
-
var _obj = PowiainaNum.fromObject(arg1);
|
|
478
|
-
this.resetFromObject(_obj);
|
|
479
482
|
} else if (typeof arg1 == "string") {
|
|
480
|
-
var
|
|
483
|
+
var _obj = PowiainaNum.fromString(arg1);
|
|
484
|
+
this.resetFromObject(_obj);
|
|
485
|
+
} else if (_typeof(arg1) == "object") {
|
|
486
|
+
var _obj2 = PowiainaNum.fromObject(arg1);
|
|
481
487
|
this.resetFromObject(_obj2);
|
|
482
488
|
} else if (typeof arg1 == "bigint") {
|
|
483
489
|
var _obj3 = PowiainaNum.fromBigInt(arg1);
|
|
@@ -501,25 +507,25 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
501
507
|
key: "add",
|
|
502
508
|
value: function add(other) {
|
|
503
509
|
var _a, _b, _c, _d;
|
|
504
|
-
var x = this.
|
|
510
|
+
var x = this.normalize();
|
|
505
511
|
var y = new PowiainaNum(other);
|
|
506
512
|
// inf + -inf = nan
|
|
507
513
|
if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY)) {
|
|
508
514
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
509
|
-
return PowiainaNum.NaN
|
|
515
|
+
return PowiainaNum.NaN;
|
|
510
516
|
}
|
|
511
517
|
// inf & nan check
|
|
512
|
-
if (!x.isFinite()) return x
|
|
513
|
-
if (!y.isFinite()) return y
|
|
518
|
+
if (!x.isFinite()) return x;
|
|
519
|
+
if (!y.isFinite()) return y;
|
|
514
520
|
// if x or y = 0, return other.
|
|
515
|
-
if (x.isZero()) return y
|
|
516
|
-
if (y.isZero()) return x
|
|
521
|
+
if (x.isZero()) return y;
|
|
522
|
+
if (y.isZero()) return x;
|
|
517
523
|
// x+ -x = 0
|
|
518
524
|
if (x.sign == -y.sign && function () {
|
|
519
525
|
var a = x.abs();
|
|
520
526
|
var b = y.abs();
|
|
521
527
|
return a.eq(b);
|
|
522
|
-
}()) return PowiainaNum.ZERO
|
|
528
|
+
}()) return PowiainaNum.ZERO;
|
|
523
529
|
// Run pure number calculates in there
|
|
524
530
|
if (x.abs().lt(MSI) && y.abs().lt(MSI)) {
|
|
525
531
|
if (x.abs().gte(MSI_REC) && y.abs().gte(MSI_REC)) return PowiainaNum.fromNumber(x.toNumber() + y.toNumber());
|
|
@@ -568,8 +574,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
568
574
|
resultLogarithm = Math.log10(-offsetedResult) - offset;
|
|
569
575
|
signMult *= -1;
|
|
570
576
|
}
|
|
571
|
-
if (offsetedResult == 0) return PowiainaNum.ZERO
|
|
572
|
-
var resultPN = PowiainaNum.NaN
|
|
577
|
+
if (offsetedResult == 0) return PowiainaNum.ZERO;
|
|
578
|
+
var resultPN = PowiainaNum.NaN;
|
|
573
579
|
resultPN.sign = 1;
|
|
574
580
|
/** abs(resultLogarithm) > 15.9, use 10^x form. */
|
|
575
581
|
if (resultLogarithm > MSI_LOG10 || resultLogarithm < -MSI_LOG10) {
|
|
@@ -600,19 +606,19 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
600
606
|
}, {
|
|
601
607
|
key: "mul",
|
|
602
608
|
value: function mul(other) {
|
|
603
|
-
var x = this
|
|
609
|
+
var x = this;
|
|
604
610
|
var y = new PowiainaNum(other);
|
|
605
611
|
// inf * -inf = -inf
|
|
606
|
-
if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || y.eq(PowiainaNum.POSITIVE_INFINITY) && x.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.NEGATIVE_INFINITY
|
|
612
|
+
if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || y.eq(PowiainaNum.POSITIVE_INFINITY) && x.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.NEGATIVE_INFINITY;
|
|
607
613
|
if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero()) {
|
|
608
614
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
609
|
-
return PowiainaNum.NaN
|
|
615
|
+
return PowiainaNum.NaN;
|
|
610
616
|
}
|
|
611
|
-
if (x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.POSITIVE_INFINITY
|
|
617
|
+
if (x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.POSITIVE_INFINITY;
|
|
612
618
|
// inf & nan check
|
|
613
|
-
if (!x.isFinite()) return x
|
|
614
|
-
if (!y.isFinite()) return y
|
|
615
|
-
if (x.isZero() || y.isZero()) return PowiainaNum.ZERO
|
|
619
|
+
if (!x.isFinite()) return x;
|
|
620
|
+
if (!y.isFinite()) return y;
|
|
621
|
+
if (x.isZero() || y.isZero()) return PowiainaNum.ZERO;
|
|
616
622
|
// x* x^-1 = 0
|
|
617
623
|
/* if (x.small==1-y.small&&(function(){
|
|
618
624
|
let a = x.abs();
|
|
@@ -673,7 +679,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
673
679
|
var _a, _b;
|
|
674
680
|
var thisObject = this.clone();
|
|
675
681
|
// inf & nan check
|
|
676
|
-
if (!this.isFinite()) return this
|
|
682
|
+
if (!this.isFinite()) return this;
|
|
677
683
|
/** when 10^(t), t<0, use 10^(-t) reciprocate. */
|
|
678
684
|
if (thisObject.isneg()) {
|
|
679
685
|
// 10^(-x) = 1/(10^x)
|
|
@@ -700,9 +706,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
700
706
|
key: "pow",
|
|
701
707
|
value: function pow(x) {
|
|
702
708
|
var other = new PowiainaNum(x);
|
|
703
|
-
if (this.eq(1)) return PowiainaNum.ONE
|
|
704
|
-
if (!other.isFinite()) return other
|
|
705
|
-
if (!this.isFinite()) return this
|
|
709
|
+
if (this.eq(1)) return PowiainaNum.ONE;
|
|
710
|
+
if (!other.isFinite()) return other;
|
|
711
|
+
if (!this.isFinite()) return this;
|
|
706
712
|
if (this.eq(10)) return other.pow10();
|
|
707
713
|
if (other.isneg()) return this.pow(other.neg()).rec();
|
|
708
714
|
if (this.isneg()) {
|
|
@@ -713,7 +719,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
713
719
|
}
|
|
714
720
|
}
|
|
715
721
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
716
|
-
return PowiainaNum.NaN
|
|
722
|
+
return PowiainaNum.NaN;
|
|
717
723
|
}
|
|
718
724
|
var r = this.abs().pow(other);
|
|
719
725
|
r.sign = function () {
|
|
@@ -731,10 +737,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
731
737
|
return PowiainaNum.fromNumber(t);
|
|
732
738
|
}
|
|
733
739
|
if (this.isZero() && other.isZero()) {
|
|
734
|
-
return PowiainaNum.ONE
|
|
740
|
+
return PowiainaNum.ONE;
|
|
735
741
|
}
|
|
736
|
-
if (this.isZero()) return PowiainaNum.ZERO
|
|
737
|
-
if (other.isZero()) return PowiainaNum.ONE
|
|
742
|
+
if (this.isZero()) return PowiainaNum.ZERO;
|
|
743
|
+
if (other.isZero()) return PowiainaNum.ONE;
|
|
738
744
|
// if this<0, check other' rec is oddd
|
|
739
745
|
if (this.gt(0)) {
|
|
740
746
|
// log10(a^b) = b log10(a)
|
|
@@ -743,7 +749,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
743
749
|
return this.neg().log10().mul(other).pow10().neg();
|
|
744
750
|
}
|
|
745
751
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
746
|
-
return PowiainaNum.NaN
|
|
752
|
+
return PowiainaNum.NaN;
|
|
747
753
|
}
|
|
748
754
|
}, {
|
|
749
755
|
key: "pow_base",
|
|
@@ -772,16 +778,16 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
772
778
|
value: function log10() {
|
|
773
779
|
if (this.isneg()) {
|
|
774
780
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
775
|
-
return PowiainaNum.NaN
|
|
781
|
+
return PowiainaNum.NaN;
|
|
776
782
|
}
|
|
777
|
-
if (this.isZero()) return PowiainaNum.NEGATIVE_INFINITY
|
|
783
|
+
if (this.isZero()) return PowiainaNum.NEGATIVE_INFINITY;
|
|
778
784
|
if (this.small) {
|
|
779
785
|
var _x = this.clone();
|
|
780
786
|
_x.small = !_x.small;
|
|
781
787
|
return _x.log10().neg();
|
|
782
788
|
}
|
|
783
789
|
if (this.array.length == 1) return new PowiainaNum(Math.log10(this.array[0].repeat));
|
|
784
|
-
if (this.gte(PowiainaNum.TETRATED_MSI)) return this
|
|
790
|
+
if (this.gte(PowiainaNum.TETRATED_MSI)) return this;
|
|
785
791
|
var x = this.clone();
|
|
786
792
|
x.array[1].repeat = x.array[1].repeat - 1;
|
|
787
793
|
x.normalize();
|
|
@@ -916,7 +922,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
916
922
|
var principal = princ;
|
|
917
923
|
if (this.lt(-0.3678794411710499)) {
|
|
918
924
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
919
|
-
return PowiainaNum.NaN
|
|
925
|
+
return PowiainaNum.NaN; //complex
|
|
920
926
|
} else if (principal) {
|
|
921
927
|
if (this.abs().lt("1e-300")) return new PowiainaNum(this);else if (this.small) {
|
|
922
928
|
return PowiainaNum.fromNumber(f_lambertw(this.toNumber()));
|
|
@@ -931,7 +937,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
931
937
|
} else {
|
|
932
938
|
if (this.sign === -1) {
|
|
933
939
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
934
|
-
return PowiainaNum.NaN
|
|
940
|
+
return PowiainaNum.NaN; //complex
|
|
935
941
|
}
|
|
936
942
|
if (this.lt(9e15)) {
|
|
937
943
|
return PowiainaNum.fromNumber(f_lambertw(this.sign * this.array[0].repeat, 1e-10, false));
|
|
@@ -951,44 +957,44 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
951
957
|
// Code from ExpantaNum.js
|
|
952
958
|
function tetrate(other2) {
|
|
953
959
|
var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
954
|
-
var t = this
|
|
960
|
+
var t = this;
|
|
955
961
|
var other = new PowiainaNum(other2);
|
|
956
962
|
var payl = new PowiainaNum(payload);
|
|
957
963
|
if (t.isNaN() || other.isNaN() || payl.isNaN()) {
|
|
958
964
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
959
|
-
return PowiainaNum.NaN
|
|
965
|
+
return PowiainaNum.NaN;
|
|
960
966
|
}
|
|
961
|
-
if (t.eq(1)) return PowiainaNum.ONE
|
|
967
|
+
if (t.eq(1)) return PowiainaNum.ONE;
|
|
962
968
|
if (payl.neq(PowiainaNum.ONE) && t.gte(EXP_E_REC)) {
|
|
963
969
|
other = other.add(payl.slog(t));
|
|
964
970
|
}
|
|
965
971
|
var negln;
|
|
966
972
|
if (other.isInfi() && other.sign > 0) {
|
|
967
|
-
if (t.gte(EXP_E_REC)) return PowiainaNum.POSITIVE_INFINITY
|
|
973
|
+
if (t.gte(EXP_E_REC)) return PowiainaNum.POSITIVE_INFINITY;
|
|
968
974
|
negln = this.log().neg();
|
|
969
975
|
return negln.lambertw().div(negln);
|
|
970
976
|
}
|
|
971
977
|
if (other.lte(-2)) {
|
|
972
978
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
973
|
-
return PowiainaNum.NaN
|
|
979
|
+
return PowiainaNum.NaN;
|
|
974
980
|
}
|
|
975
981
|
if (t.isZero()) {
|
|
976
982
|
if (other.isZero()) {
|
|
977
983
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
978
|
-
return PowiainaNum.NaN
|
|
984
|
+
return PowiainaNum.NaN;
|
|
979
985
|
}
|
|
980
|
-
if (other.gte(MSI / 2) || other.toNumber() % 2 == 0) return PowiainaNum.ZERO
|
|
981
|
-
return PowiainaNum.ONE
|
|
986
|
+
if (other.gte(MSI / 2) || other.toNumber() % 2 == 0) return PowiainaNum.ZERO;
|
|
987
|
+
return PowiainaNum.ONE;
|
|
982
988
|
}
|
|
983
989
|
if (t.eq(PowiainaNum.ONE)) {
|
|
984
990
|
if (other.eq(PowiainaNum.ONE.neg())) {
|
|
985
991
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
986
|
-
return PowiainaNum.NaN
|
|
992
|
+
return PowiainaNum.NaN;
|
|
987
993
|
}
|
|
988
|
-
return PowiainaNum.ONE
|
|
994
|
+
return PowiainaNum.ONE;
|
|
989
995
|
}
|
|
990
|
-
if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.ZERO
|
|
991
|
-
if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE
|
|
996
|
+
if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.ZERO;
|
|
997
|
+
if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE;
|
|
992
998
|
if (other.eq(PowiainaNum.ONE)) return t;
|
|
993
999
|
if (other.eq(2)) return t.pow(t);
|
|
994
1000
|
if (t.eq(2)) {
|
|
@@ -1012,7 +1018,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1012
1018
|
var r = t.pow(y - f);
|
|
1013
1019
|
var l = PowiainaNum.NaN;
|
|
1014
1020
|
var i = 0;
|
|
1015
|
-
for (var w = PowiainaNum.E_MSI
|
|
1021
|
+
for (var w = PowiainaNum.E_MSI; f !== 0 && r.lt(w) && i < 100; ++i) {
|
|
1016
1022
|
if (f > 0) {
|
|
1017
1023
|
r = t.pow(r);
|
|
1018
1024
|
if (l.eq(r)) {
|
|
@@ -1047,25 +1053,25 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1047
1053
|
key: "slog",
|
|
1048
1054
|
value: function slog() {
|
|
1049
1055
|
var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1050
|
-
var x = this
|
|
1056
|
+
var x = this;
|
|
1051
1057
|
var b = new PowiainaNum(base);
|
|
1052
1058
|
if (x.isInfiNaN()) return x;
|
|
1053
1059
|
if (b.isNaN()) return b;
|
|
1054
|
-
if (b.isInfi()) return PowiainaNum.ZERO
|
|
1055
|
-
if (x.isZero()) return PowiainaNum.ONE
|
|
1056
|
-
if (x.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO
|
|
1057
|
-
if (x.eq(b)) return PowiainaNum.ONE
|
|
1060
|
+
if (b.isInfi()) return PowiainaNum.ZERO;
|
|
1061
|
+
if (x.isZero()) return PowiainaNum.ONE;
|
|
1062
|
+
if (x.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO;
|
|
1063
|
+
if (x.eq(b)) return PowiainaNum.ONE;
|
|
1058
1064
|
if (b.lt(EXP_E_REC)) {
|
|
1059
1065
|
var a = b.tetrate(Infinity);
|
|
1060
|
-
if (x.eq(a)) return PowiainaNum.POSITIVE_INFINITY
|
|
1066
|
+
if (x.eq(a)) return PowiainaNum.POSITIVE_INFINITY;
|
|
1061
1067
|
if (x.gt(a)) {
|
|
1062
1068
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1063
|
-
return PowiainaNum.NaN
|
|
1069
|
+
return PowiainaNum.NaN;
|
|
1064
1070
|
}
|
|
1065
1071
|
}
|
|
1066
1072
|
if (x.max(b).gt(PowiainaNum.PENTATED_MSI)) {
|
|
1067
1073
|
if (x.gt(b)) return x;
|
|
1068
|
-
return PowiainaNum.ZERO
|
|
1074
|
+
return PowiainaNum.ZERO;
|
|
1069
1075
|
}
|
|
1070
1076
|
if (x.max(b).gt(PowiainaNum.TETRATED_MSI)) {
|
|
1071
1077
|
if (x.gt(b)) {
|
|
@@ -1074,7 +1080,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1074
1080
|
return x.sub(x.getOperator(1));
|
|
1075
1081
|
}
|
|
1076
1082
|
}
|
|
1077
|
-
if (x.lt(PowiainaNum.ZERO
|
|
1083
|
+
if (x.lt(PowiainaNum.ZERO)) return b.pow(x).sub(2);
|
|
1078
1084
|
// base^base^... = x? (? bases)
|
|
1079
1085
|
var r = 0;
|
|
1080
1086
|
// 计算x与base的差距
|
|
@@ -1106,15 +1112,15 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1106
1112
|
}
|
|
1107
1113
|
if (x.gt(10)) return new PowiainaNum(r);
|
|
1108
1114
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1109
|
-
return PowiainaNum.NaN
|
|
1115
|
+
return PowiainaNum.NaN;
|
|
1110
1116
|
}
|
|
1111
1117
|
}, {
|
|
1112
1118
|
key: "ssqrt",
|
|
1113
1119
|
value: function ssqrt() {
|
|
1114
|
-
var x = this
|
|
1120
|
+
var x = this;
|
|
1115
1121
|
if (x.lt(1 / EXP_E_REC)) {
|
|
1116
1122
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1117
|
-
return PowiainaNum.NaN
|
|
1123
|
+
return PowiainaNum.NaN;
|
|
1118
1124
|
}
|
|
1119
1125
|
if (!x.isFinite()) return x;
|
|
1120
1126
|
if (x.gt(PowiainaNum.TETRATED_MSI)) return x;
|
|
@@ -1142,7 +1148,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1142
1148
|
function iteratedlog() {
|
|
1143
1149
|
var other2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
1144
1150
|
var base2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
1145
|
-
var t = this
|
|
1151
|
+
var t = this;
|
|
1146
1152
|
var base = new PowiainaNum(base2);
|
|
1147
1153
|
var other = new PowiainaNum(other2);
|
|
1148
1154
|
if (other.isZero()) return t;
|
|
@@ -1155,10 +1161,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1155
1161
|
var bbase = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1156
1162
|
var EPSILON = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e-6;
|
|
1157
1163
|
var target = this;
|
|
1158
|
-
var dis = target
|
|
1164
|
+
var dis = target;
|
|
1159
1165
|
if (dis.isInfiNaN()) return dis;
|
|
1160
1166
|
if (dis.gte("10{1,2}e15.954589770191003")) return dis;
|
|
1161
|
-
var base = new PowiainaNum(bbase)
|
|
1167
|
+
var base = new PowiainaNum(bbase);
|
|
1162
1168
|
if (dis.getOperator(1 / 0) >= 1) {
|
|
1163
1169
|
dis.setOperator(dis.getOperator(1 / 0) - 1, 1 / 0, 1, 1);
|
|
1164
1170
|
return dis;
|
|
@@ -1249,13 +1255,13 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1249
1255
|
}, {
|
|
1250
1256
|
key: "arrow",
|
|
1251
1257
|
value: function arrow(arrows2) {
|
|
1252
|
-
var t = this
|
|
1258
|
+
var t = this;
|
|
1253
1259
|
var arrows = new PowiainaNum(arrows2);
|
|
1254
1260
|
if (arrows.lt(PowiainaNum.ZERO)) {
|
|
1255
1261
|
console.warn("The arrow is <0 or not a integer, the returned function will return NaN.");
|
|
1256
1262
|
return function () {
|
|
1257
1263
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1258
|
-
return PowiainaNum.NaN
|
|
1264
|
+
return PowiainaNum.NaN;
|
|
1259
1265
|
};
|
|
1260
1266
|
}
|
|
1261
1267
|
if (!arrows.isInt()) {
|
|
@@ -1278,23 +1284,23 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1278
1284
|
var other = new PowiainaNum(other2);
|
|
1279
1285
|
var payload = new PowiainaNum(payload2);
|
|
1280
1286
|
var ctt = PowiainaNum.arrowFuncMap.get("".concat(t.toString(), " ").concat(arrows.toString(), " ").concat(other.toString(), " ").concat(depth));
|
|
1281
|
-
if (ctt) return ctt
|
|
1287
|
+
if (ctt) return ctt;
|
|
1282
1288
|
var res = function () {
|
|
1283
1289
|
var calcBase;
|
|
1284
|
-
if (t.isNaN() || other.isNaN() || payload.isNaN()) return PowiainaNum.NaN
|
|
1285
|
-
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN
|
|
1290
|
+
if (t.isNaN() || other.isNaN() || payload.isNaN()) return PowiainaNum.NaN;
|
|
1291
|
+
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN;
|
|
1286
1292
|
if (t.eq(PowiainaNum.ZERO)) {
|
|
1287
|
-
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO
|
|
1293
|
+
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO;
|
|
1288
1294
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1289
|
-
return PowiainaNum.NaN
|
|
1295
|
+
return PowiainaNum.NaN;
|
|
1290
1296
|
}
|
|
1291
1297
|
if (payload.neq(PowiainaNum.ONE)) other = other.add(payload.anyarrow_log(arrows)(t));
|
|
1292
|
-
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE
|
|
1293
|
-
if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE
|
|
1294
|
-
if (other.eq(PowiainaNum.ONE)) return t
|
|
1298
|
+
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE;
|
|
1299
|
+
if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE;
|
|
1300
|
+
if (other.eq(PowiainaNum.ONE)) return t;
|
|
1295
1301
|
// arrow > 9e15, that using 10{x}, x=arrow;
|
|
1296
1302
|
if (arrows.gt(PowiainaNum.MSI)) {
|
|
1297
|
-
calcBase = arrows
|
|
1303
|
+
calcBase = arrows;
|
|
1298
1304
|
calcBase.setOperator(calcBase.getOperator(Infinity) + 1, Infinity);
|
|
1299
1305
|
return calcBase;
|
|
1300
1306
|
}
|
|
@@ -1305,7 +1311,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1305
1311
|
if (t.max(other).gt(PowiainaNum.arrowMSI(arrowsNum + 1))) return t.max(other);
|
|
1306
1312
|
if (t.gt(PowiainaNum.arrowMSI(arrowsNum)) || other.gt(MSI)) {
|
|
1307
1313
|
if (t.gt(PowiainaNum.arrowMSI(arrowsNum))) {
|
|
1308
|
-
calcBase = t
|
|
1314
|
+
calcBase = t;
|
|
1309
1315
|
calcBase.setOperator(calcBase.getOperator(arrowsNum) - 1, arrowsNum);
|
|
1310
1316
|
calcBase.normalize();
|
|
1311
1317
|
} else if (t.gt(PowiainaNum.arrowMSI(arrowsNum - 1))) {
|
|
@@ -1344,7 +1350,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1344
1350
|
return calcBase;
|
|
1345
1351
|
}();
|
|
1346
1352
|
if (depth < PowiainaNum.maxOps + 10) {
|
|
1347
|
-
PowiainaNum.arrowFuncMap.set("".concat(t.toString(), " ").concat(arrows.toString(), " ").concat(other.toString(), " ").concat(depth), res
|
|
1353
|
+
PowiainaNum.arrowFuncMap.set("".concat(t.toString(), " ").concat(arrows.toString(), " ").concat(other.toString(), " ").concat(depth), res);
|
|
1348
1354
|
}
|
|
1349
1355
|
return res;
|
|
1350
1356
|
};
|
|
@@ -1359,7 +1365,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1359
1365
|
* @returns
|
|
1360
1366
|
*/
|
|
1361
1367
|
function anyarrow_log(arrow2) {
|
|
1362
|
-
var x = this
|
|
1368
|
+
var x = this;
|
|
1363
1369
|
var arrow = new PowiainaNum(arrow2);
|
|
1364
1370
|
var arrowsNum = arrow.toNumber();
|
|
1365
1371
|
if (arrow.gt(MSI)) {
|
|
@@ -1367,7 +1373,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1367
1373
|
}
|
|
1368
1374
|
if (!arrow.isInt() || arrow.lt(0)) return function () {
|
|
1369
1375
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1370
|
-
return PowiainaNum.NaN
|
|
1376
|
+
return PowiainaNum.NaN;
|
|
1371
1377
|
};
|
|
1372
1378
|
if (arrow.eq(0)) return function (base) {
|
|
1373
1379
|
return x.div(base);
|
|
@@ -1385,13 +1391,13 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1385
1391
|
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1386
1392
|
var b = new PowiainaNum(base);
|
|
1387
1393
|
if (b.isNaN()) return b;
|
|
1388
|
-
if (b.isInfi()) return PowiainaNum.ZERO
|
|
1389
|
-
if (x.isZero()) return PowiainaNum.ONE
|
|
1390
|
-
if (x.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO
|
|
1391
|
-
if (x.eq(b)) return PowiainaNum.ONE
|
|
1394
|
+
if (b.isInfi()) return PowiainaNum.ZERO;
|
|
1395
|
+
if (x.isZero()) return PowiainaNum.ONE;
|
|
1396
|
+
if (x.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO;
|
|
1397
|
+
if (x.eq(b)) return PowiainaNum.ONE;
|
|
1392
1398
|
if (x.max(b).gt(PowiainaNum.arrowMSI(arrowsNum + 1))) {
|
|
1393
1399
|
if (x.gt(b)) return x;
|
|
1394
|
-
return PowiainaNum.ZERO
|
|
1400
|
+
return PowiainaNum.ZERO;
|
|
1395
1401
|
}
|
|
1396
1402
|
if (x.max(b).gt(PowiainaNum.arrowMSI(arrowsNum))) {
|
|
1397
1403
|
if (x.gt(b)) {
|
|
@@ -1400,9 +1406,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1400
1406
|
return x.sub(x.getOperator(arrowsNum - 1));
|
|
1401
1407
|
}
|
|
1402
1408
|
}
|
|
1403
|
-
if (x.lt(PowiainaNum.ZERO
|
|
1409
|
+
if (x.lt(PowiainaNum.ZERO)) {
|
|
1404
1410
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1405
|
-
return PowiainaNum.NaN
|
|
1411
|
+
return PowiainaNum.NaN;
|
|
1406
1412
|
}
|
|
1407
1413
|
// base^base^... = x? (? bases)
|
|
1408
1414
|
var r = 0;
|
|
@@ -1428,7 +1434,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1428
1434
|
}
|
|
1429
1435
|
if (x.gt(10)) return new PowiainaNum(r);
|
|
1430
1436
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1431
|
-
return PowiainaNum.NaN
|
|
1437
|
+
return PowiainaNum.NaN;
|
|
1432
1438
|
};
|
|
1433
1439
|
}
|
|
1434
1440
|
}, {
|
|
@@ -1440,7 +1446,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1440
1446
|
var dis = target.clone();
|
|
1441
1447
|
if (dis.isInfiNaN()) return dis;
|
|
1442
1448
|
if (dis.gte("10{1,3}e15.954589770191003")) return dis;
|
|
1443
|
-
new PowiainaNum(bbase)
|
|
1449
|
+
new PowiainaNum(bbase);
|
|
1444
1450
|
if (dis.getOperator(1 / 0, 2) >= 1) {
|
|
1445
1451
|
dis.setOperator(dis.getOperator(1 / 0) - 1, 1 / 0, 2, 1);
|
|
1446
1452
|
return dis;
|
|
@@ -1583,12 +1589,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1583
1589
|
*/
|
|
1584
1590
|
function expansion(other2) {
|
|
1585
1591
|
var other = new PowiainaNum(other2);
|
|
1586
|
-
var t = this
|
|
1587
|
-
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN
|
|
1588
|
-
if (other.eq(PowiainaNum.ONE)) return this
|
|
1589
|
-
if (this.eq(PowiainaNum.ONE)) return PowiainaNum.ONE
|
|
1592
|
+
var t = this;
|
|
1593
|
+
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN;
|
|
1594
|
+
if (other.eq(PowiainaNum.ONE)) return this;
|
|
1595
|
+
if (this.eq(PowiainaNum.ONE)) return PowiainaNum.ONE;
|
|
1590
1596
|
if (this.eq(2)) return new PowiainaNum(4);
|
|
1591
|
-
if (other.eq(0)) return PowiainaNum.ONE
|
|
1597
|
+
if (other.eq(0)) return PowiainaNum.ONE;
|
|
1592
1598
|
if (other.gt(0) && other.lt(1) && !other.isInt()) {
|
|
1593
1599
|
return t.pow(other);
|
|
1594
1600
|
}
|
|
@@ -1632,10 +1638,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1632
1638
|
key: "expansionArrow",
|
|
1633
1639
|
value: function expansionArrow(arrow2) {
|
|
1634
1640
|
var arrow = new PowiainaNum(arrow2);
|
|
1635
|
-
var t = this
|
|
1641
|
+
var t = this;
|
|
1636
1642
|
if (arrow.lt(0) || !arrow.isInt()) return function () {
|
|
1637
1643
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1638
|
-
return PowiainaNum.NaN
|
|
1644
|
+
return PowiainaNum.NaN;
|
|
1639
1645
|
};
|
|
1640
1646
|
if (arrow.eq(0)) return function (other) {
|
|
1641
1647
|
return t.arrow(other)(t);
|
|
@@ -1648,22 +1654,22 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1648
1654
|
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1649
1655
|
var other = new PowiainaNum(other2);
|
|
1650
1656
|
var r;
|
|
1651
|
-
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN
|
|
1657
|
+
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN;
|
|
1652
1658
|
if (other.lt(PowiainaNum.ZERO)) {
|
|
1653
1659
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1654
|
-
return PowiainaNum.NaN
|
|
1660
|
+
return PowiainaNum.NaN;
|
|
1655
1661
|
}
|
|
1656
1662
|
if (t.eq(PowiainaNum.ZERO)) {
|
|
1657
|
-
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO
|
|
1663
|
+
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO;
|
|
1658
1664
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1659
|
-
return PowiainaNum.NaN
|
|
1665
|
+
return PowiainaNum.NaN;
|
|
1660
1666
|
}
|
|
1661
|
-
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE
|
|
1662
|
-
if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE
|
|
1663
|
-
if (other.eq(PowiainaNum.ONE)) return t
|
|
1667
|
+
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE;
|
|
1668
|
+
if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE;
|
|
1669
|
+
if (other.eq(PowiainaNum.ONE)) return t;
|
|
1664
1670
|
// arrow > 9e15, that using 10{x,2}, x=arrow;
|
|
1665
1671
|
if (arrows.gt(PowiainaNum.MSI)) {
|
|
1666
|
-
r = arrows
|
|
1672
|
+
r = arrows;
|
|
1667
1673
|
r.setOperator(r.getOperator(Infinity, 2) + 1, Infinity, 2);
|
|
1668
1674
|
return r;
|
|
1669
1675
|
}
|
|
@@ -1715,9 +1721,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1715
1721
|
}, {
|
|
1716
1722
|
key: "expansion_log_inner",
|
|
1717
1723
|
value: function expansion_log_inner(base2) {
|
|
1718
|
-
var t = this
|
|
1724
|
+
var t = this;
|
|
1719
1725
|
var base = new PowiainaNum(base2);
|
|
1720
|
-
if (base.eq(2) && t.gt(4)) return PowiainaNum.NaN
|
|
1726
|
+
if (base.eq(2) && t.gt(4)) return PowiainaNum.NaN;
|
|
1721
1727
|
if (t.gte("10{2,2}".concat(MSI))) {
|
|
1722
1728
|
return t;
|
|
1723
1729
|
}
|
|
@@ -1726,7 +1732,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1726
1732
|
return t;
|
|
1727
1733
|
}
|
|
1728
1734
|
var r = 0;
|
|
1729
|
-
var x = t
|
|
1735
|
+
var x = t;
|
|
1730
1736
|
var morexxxoperators = 0;
|
|
1731
1737
|
if (x.getOperator(1 / 0) >= 10) {
|
|
1732
1738
|
morexxxoperators = x.getOperator(1 / 0) - 10;
|
|
@@ -1764,7 +1770,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1764
1770
|
}
|
|
1765
1771
|
if (!arrow.isInt() || arrow.lt(1)) return function () {
|
|
1766
1772
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1767
|
-
return PowiainaNum.NaN
|
|
1773
|
+
return PowiainaNum.NaN;
|
|
1768
1774
|
};
|
|
1769
1775
|
if (arrow.eq(1)) return function (base) {
|
|
1770
1776
|
return x.expansion_log_inner(base);
|
|
@@ -1776,13 +1782,13 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1776
1782
|
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
1777
1783
|
var b = new PowiainaNum(base);
|
|
1778
1784
|
if (b.isNaN()) return b;
|
|
1779
|
-
if (b.isInfi()) return PowiainaNum.ZERO
|
|
1780
|
-
if (x.isZero()) return PowiainaNum.ONE
|
|
1781
|
-
if (x.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO
|
|
1782
|
-
if (x.eq(b)) return PowiainaNum.ONE
|
|
1785
|
+
if (b.isInfi()) return PowiainaNum.ZERO;
|
|
1786
|
+
if (x.isZero()) return PowiainaNum.ONE;
|
|
1787
|
+
if (x.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO;
|
|
1788
|
+
if (x.eq(b)) return PowiainaNum.ONE;
|
|
1783
1789
|
if (x.max(b).gt(PowiainaNum.arrowexpansMSI(arrowsNum + 1))) {
|
|
1784
1790
|
if (x.gt(b)) return x;
|
|
1785
|
-
return PowiainaNum.ZERO
|
|
1791
|
+
return PowiainaNum.ZERO;
|
|
1786
1792
|
}
|
|
1787
1793
|
if (x.max(b).gt(PowiainaNum.arrowexpansMSI(arrowsNum))) {
|
|
1788
1794
|
if (x.gt(b)) {
|
|
@@ -1791,9 +1797,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1791
1797
|
return x.sub(x.getOperator(arrowsNum - 1, 2));
|
|
1792
1798
|
}
|
|
1793
1799
|
}
|
|
1794
|
-
if (x.lt(PowiainaNum.ZERO
|
|
1800
|
+
if (x.lt(PowiainaNum.ZERO)) {
|
|
1795
1801
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1796
|
-
return PowiainaNum.NaN
|
|
1802
|
+
return PowiainaNum.NaN;
|
|
1797
1803
|
}
|
|
1798
1804
|
// base^base^... = x? (? bases)
|
|
1799
1805
|
var r = 0;
|
|
@@ -1819,7 +1825,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1819
1825
|
}
|
|
1820
1826
|
if (x.gt(10)) return new PowiainaNum(r);
|
|
1821
1827
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1822
|
-
return PowiainaNum.NaN
|
|
1828
|
+
return PowiainaNum.NaN;
|
|
1823
1829
|
};
|
|
1824
1830
|
}
|
|
1825
1831
|
}, {
|
|
@@ -2058,7 +2064,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2058
2064
|
}, {
|
|
2059
2065
|
key: "sin",
|
|
2060
2066
|
value: function sin() {
|
|
2061
|
-
var x = this
|
|
2067
|
+
var x = this;
|
|
2062
2068
|
if (x.isneg()) {
|
|
2063
2069
|
return x.neg().sin().neg();
|
|
2064
2070
|
}
|
|
@@ -2120,9 +2126,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2120
2126
|
}, {
|
|
2121
2127
|
key: "floor",
|
|
2122
2128
|
value: function floor() {
|
|
2123
|
-
if (this.isInt()) return this
|
|
2129
|
+
if (this.isInt()) return this;
|
|
2124
2130
|
if (this.small) {
|
|
2125
|
-
if (this.sign == 1) return PowiainaNum.ZERO
|
|
2131
|
+
if (this.sign == 1) return PowiainaNum.ZERO;else return PowiainaNum.ONE.neg();
|
|
2126
2132
|
}
|
|
2127
2133
|
var r = this.abs();
|
|
2128
2134
|
r.array[0].repeat = Math[this.sign == 1 ? "floor" : "ceil"](r.getOperator(0));
|
|
@@ -2132,9 +2138,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2132
2138
|
}, {
|
|
2133
2139
|
key: "ceil",
|
|
2134
2140
|
value: function ceil() {
|
|
2135
|
-
if (this.isInt()) return this
|
|
2141
|
+
if (this.isInt()) return this;
|
|
2136
2142
|
if (this.small) {
|
|
2137
|
-
if (this.sign == 1) return PowiainaNum.ONE
|
|
2143
|
+
if (this.sign == 1) return PowiainaNum.ONE;else return PowiainaNum.ZERO;
|
|
2138
2144
|
}
|
|
2139
2145
|
var r = this.abs();
|
|
2140
2146
|
r.array[0].repeat = Math[this.sign == 1 ? "ceil" : "floor"](r.getOperator(0));
|
|
@@ -2144,12 +2150,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2144
2150
|
}, {
|
|
2145
2151
|
key: "round",
|
|
2146
2152
|
value: function round() {
|
|
2147
|
-
if (this.isInt()) return this
|
|
2153
|
+
if (this.isInt()) return this;
|
|
2148
2154
|
if (this.small) {
|
|
2149
2155
|
if (this.sign == 1) {
|
|
2150
|
-
if (this.rec().lte(2)) return PowiainaNum.ONE
|
|
2156
|
+
if (this.rec().lte(2)) return PowiainaNum.ONE;else return PowiainaNum.ZERO;
|
|
2151
2157
|
} else {
|
|
2152
|
-
if (this.abs().rec().lte(2)) return PowiainaNum.ZERO
|
|
2158
|
+
if (this.abs().rec().lte(2)) return PowiainaNum.ZERO;else return PowiainaNum.ONE.neg();
|
|
2153
2159
|
}
|
|
2154
2160
|
}
|
|
2155
2161
|
var r = this.abs();
|
|
@@ -2173,7 +2179,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2173
2179
|
* @returns
|
|
2174
2180
|
*/
|
|
2175
2181
|
function trunc() {
|
|
2176
|
-
var y = this
|
|
2182
|
+
var y = this;
|
|
2177
2183
|
return y.gte(0) ? y.floor() : y.ceil();
|
|
2178
2184
|
}
|
|
2179
2185
|
}, {
|
|
@@ -2442,27 +2448,30 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2442
2448
|
// Sort arrays.
|
|
2443
2449
|
this.array.sort(arraySortFunction);
|
|
2444
2450
|
for (var _i2 = 1; _i2 < x.array.length - 1; ++_i2) {
|
|
2445
|
-
|
|
2451
|
+
var q = x.array[_i2];
|
|
2452
|
+
var r = x.array[_i2 + 1];
|
|
2453
|
+
if (q.arrow == r.arrow && q.expans == r.expans && q.megota == r.megota) {
|
|
2446
2454
|
// same array's merge
|
|
2447
|
-
|
|
2455
|
+
q.repeat += r.repeat;
|
|
2448
2456
|
x.array.splice(_i2 + 1, 1);
|
|
2449
2457
|
--_i2;
|
|
2450
2458
|
renormalize = true;
|
|
2451
2459
|
}
|
|
2452
2460
|
}
|
|
2453
2461
|
for (var _i3 = 1; _i3 < x.array.length; ++_i3) {
|
|
2462
|
+
var b = x.array[_i3];
|
|
2454
2463
|
// If there is a 0 repeat operator, remove it.
|
|
2455
|
-
if (
|
|
2464
|
+
if (b.arrow !== 0 && (b.repeat === 0 || b.repeat === null || b.repeat === undefined)) {
|
|
2456
2465
|
x.array.splice(_i3, 1);
|
|
2457
2466
|
--_i3;
|
|
2458
2467
|
continue;
|
|
2459
2468
|
}
|
|
2460
2469
|
// If there is a operator which arrow 0 and brace count >=2
|
|
2461
2470
|
// replace it as arrow replacement operaotr
|
|
2462
|
-
if (
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2471
|
+
if (b.arrow == 0 && b.expans >= 2) {
|
|
2472
|
+
b.arrow = Infinity;
|
|
2473
|
+
b.valuereplaced = 0;
|
|
2474
|
+
b.expans = b.expans - 1;
|
|
2466
2475
|
}
|
|
2467
2476
|
}
|
|
2468
2477
|
// for any (10{1,2})x, x< MSI turn into:
|
|
@@ -2612,10 +2621,14 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2612
2621
|
if (!powlikeObject.array) {
|
|
2613
2622
|
return;
|
|
2614
2623
|
}
|
|
2615
|
-
this.array =
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2624
|
+
this.array = powlikeObject.array.map(function (item) {
|
|
2625
|
+
return {
|
|
2626
|
+
arrow: item.arrow,
|
|
2627
|
+
expans: item.expans,
|
|
2628
|
+
megota: item.megota,
|
|
2629
|
+
repeat: item.repeat
|
|
2630
|
+
};
|
|
2631
|
+
});
|
|
2619
2632
|
this.small = powlikeObject.small;
|
|
2620
2633
|
this.sign = powlikeObject.sign;
|
|
2621
2634
|
this.layer = powlikeObject.layer;
|
|
@@ -2948,8 +2961,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2948
2961
|
key: "arrFrac",
|
|
2949
2962
|
value: function arrFrac(base, height) {
|
|
2950
2963
|
if (new PowiainaNum(height).lt(2)) return PowiainaNum.pentate(base, height);
|
|
2951
|
-
var b = new PowiainaNum(base)
|
|
2952
|
-
var h = new PowiainaNum(height)
|
|
2964
|
+
var b = new PowiainaNum(base);
|
|
2965
|
+
var h = new PowiainaNum(height);
|
|
2953
2966
|
return new PowiainaNum(b).arrow(h.floor().add(1))(b.div(2).pow(h.sub(h.floor())).mul(2));
|
|
2954
2967
|
}
|
|
2955
2968
|
/**
|
|
@@ -2959,8 +2972,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2959
2972
|
key: "arrw2Frac",
|
|
2960
2973
|
value: function arrw2Frac(base, height) {
|
|
2961
2974
|
if (new PowiainaNum(height).lt(2)) return new PowiainaNum(base).expansionArrow(3)(height);
|
|
2962
|
-
var b = new PowiainaNum(base)
|
|
2963
|
-
var h = new PowiainaNum(height)
|
|
2975
|
+
var b = new PowiainaNum(base);
|
|
2976
|
+
var h = new PowiainaNum(height);
|
|
2964
2977
|
return new PowiainaNum(b).expansionArrow(h.floor().add(1))(b.div(2).pow(h.sub(h.floor())).mul(2));
|
|
2965
2978
|
}
|
|
2966
2979
|
}, {
|
|
@@ -3034,12 +3047,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3034
3047
|
}
|
|
3035
3048
|
if (getArgs(0).eq(1)) return new PowiainaNum(1);
|
|
3036
3049
|
if (getArgs(1).eq(1)) return new PowiainaNum(getArgs(0));
|
|
3037
|
-
if (getArgs(5).eq(2) && (getArgs(4).gte(2) || getArgs(3).gte(2) || getArgs(2).gte(2))) return PowiainaNum.POSITIVE_INFINITY
|
|
3050
|
+
if (getArgs(5).eq(2) && (getArgs(4).gte(2) || getArgs(3).gte(2) || getArgs(2).gte(2))) return PowiainaNum.POSITIVE_INFINITY;
|
|
3038
3051
|
if (args.slice(6).map(function (x) {
|
|
3039
3052
|
return new PowiainaNum(x);
|
|
3040
3053
|
}).filter(function (x) {
|
|
3041
3054
|
return x.gt(1);
|
|
3042
|
-
}).length !== 0) return PowiainaNum.POSITIVE_INFINITY
|
|
3055
|
+
}).length !== 0) return PowiainaNum.POSITIVE_INFINITY;
|
|
3043
3056
|
return PowiainaNum.BEAF_core(getArgs(0), getArgs(1), getArgs(2), getArgs(3), getArgs(4), getArgs(5));
|
|
3044
3057
|
}
|
|
3045
3058
|
}, {
|
|
@@ -3064,14 +3077,14 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3064
3077
|
if (power.isZero()) return new PowiainaNum(1);
|
|
3065
3078
|
if (base.lt(0)) {
|
|
3066
3079
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
3067
|
-
return PowiainaNum.NaN
|
|
3080
|
+
return PowiainaNum.NaN;
|
|
3068
3081
|
}
|
|
3069
3082
|
// // check infinite
|
|
3070
3083
|
// let sufpowiaina = args.slice(4);
|
|
3071
3084
|
// if (sufpowiaina.filter((f) => new PowiainaNum(f).gte(2)).length > 0) {
|
|
3072
3085
|
// return PowiainaNum.POSITIVE_INFINITY;
|
|
3073
3086
|
// }
|
|
3074
|
-
if (new PowiainaNum(powiaina2).gte(3)) return PowiainaNum.POSITIVE_INFINITY
|
|
3087
|
+
if (new PowiainaNum(powiaina2).gte(3)) return PowiainaNum.POSITIVE_INFINITY;
|
|
3075
3088
|
if (readArg(0).eq(0) && readArg(1).eq(1) && readArg(2).eq(1)) {
|
|
3076
3089
|
return base.mul(power);
|
|
3077
3090
|
}
|
|
@@ -3092,10 +3105,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3092
3105
|
var megota = readArg(2);
|
|
3093
3106
|
var powiaina = readArg(3);
|
|
3094
3107
|
if (powiaina.eq(2)) {
|
|
3095
|
-
if (arrow != 1) return PowiainaNum.POSITIVE_INFINITY
|
|
3096
|
-
if (expans.neq(1)) return PowiainaNum.POSITIVE_INFINITY
|
|
3097
|
-
if (megota.neq(1)) return PowiainaNum.POSITIVE_INFINITY
|
|
3098
|
-
if (power.gte(MSI)) return PowiainaNum.POSITIVE_INFINITY
|
|
3108
|
+
if (arrow != 1) return PowiainaNum.POSITIVE_INFINITY;
|
|
3109
|
+
if (expans.neq(1)) return PowiainaNum.POSITIVE_INFINITY;
|
|
3110
|
+
if (megota.neq(1)) return PowiainaNum.POSITIVE_INFINITY;
|
|
3111
|
+
if (power.gte(MSI)) return PowiainaNum.POSITIVE_INFINITY;
|
|
3099
3112
|
var r = new PowiainaNum(10);
|
|
3100
3113
|
r.layer = power.toNumber();
|
|
3101
3114
|
r.normalize();
|
|
@@ -3131,27 +3144,27 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3131
3144
|
m = _convertOperator2[2];
|
|
3132
3145
|
return "10{".concat(infToBang(a), ",").concat(infToBang(e), ",").concat(m, "}").concat(MSI);
|
|
3133
3146
|
}
|
|
3134
|
-
var t = base
|
|
3147
|
+
var t = base;
|
|
3135
3148
|
var arrows = new PowiainaNum(readArg(0));
|
|
3136
3149
|
var result = function (other2) {
|
|
3137
3150
|
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
3138
3151
|
var ctt = PowiainaNum.beafFuncMap.get("".concat(t.toString(), " ").concat(arrow.toString(), " ").concat(expans.toString(), " ").concat(megota.toString(), " ").concat(powiaina.toString(), " ").concat(other2.toString(), " ").concat(depth));
|
|
3139
|
-
if (ctt) return ctt
|
|
3152
|
+
if (ctt) return ctt;
|
|
3140
3153
|
// console.log(
|
|
3141
3154
|
// `${"-".repeat(depth)} {${base2},${power2},${arrow2},${expans2},${megota2}}`
|
|
3142
3155
|
// );
|
|
3143
3156
|
var other = new PowiainaNum(other2);
|
|
3144
3157
|
var r;
|
|
3145
|
-
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN
|
|
3146
|
-
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN
|
|
3158
|
+
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN;
|
|
3159
|
+
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN;
|
|
3147
3160
|
if (t.eq(PowiainaNum.ZERO)) {
|
|
3148
|
-
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO
|
|
3161
|
+
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO;
|
|
3149
3162
|
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
3150
|
-
return PowiainaNum.NaN
|
|
3163
|
+
return PowiainaNum.NaN;
|
|
3151
3164
|
}
|
|
3152
|
-
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE
|
|
3153
|
-
if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE
|
|
3154
|
-
if (other.eq(PowiainaNum.ONE)) return t
|
|
3165
|
+
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE;
|
|
3166
|
+
if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE;
|
|
3167
|
+
if (other.eq(PowiainaNum.ONE)) return t;
|
|
3155
3168
|
if (arrows.eq(0)) {
|
|
3156
3169
|
return PowiainaNum.BEAF_core(t, t, power, expans.sub(1), megota, powiaina2, depth + 1);
|
|
3157
3170
|
// {this, this, power, expans-1, megota}
|
|
@@ -3227,7 +3240,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3227
3240
|
return r;
|
|
3228
3241
|
}(power, depth);
|
|
3229
3242
|
if (depth < PowiainaNum.maxOps + 10) {
|
|
3230
|
-
PowiainaNum.beafFuncMap.set("".concat(t.toString(), " ").concat(arrow.toString(), " ").concat(expans.toString(), " ").concat(megota.toString(), " ").concat(powiaina.toString(), " ").concat(power.toString(), " ").concat(depth), result
|
|
3243
|
+
PowiainaNum.beafFuncMap.set("".concat(t.toString(), " ").concat(arrow.toString(), " ").concat(expans.toString(), " ").concat(megota.toString(), " ").concat(powiaina.toString(), " ").concat(power.toString(), " ").concat(depth), result);
|
|
3231
3244
|
}
|
|
3232
3245
|
return result;
|
|
3233
3246
|
}
|
|
@@ -3248,7 +3261,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3248
3261
|
}
|
|
3249
3262
|
for (var i = 0; i < args.length; i++) {
|
|
3250
3263
|
if (max.lt(args[i])) {
|
|
3251
|
-
max = new PowiainaNum(args[i])
|
|
3264
|
+
max = new PowiainaNum(args[i]);
|
|
3252
3265
|
}
|
|
3253
3266
|
}
|
|
3254
3267
|
return max;
|
|
@@ -3265,7 +3278,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3265
3278
|
}
|
|
3266
3279
|
for (var i = 0; i < args.length; i++) {
|
|
3267
3280
|
if (max.gt(args[i])) {
|
|
3268
|
-
max = new PowiainaNum(args[i])
|
|
3281
|
+
max = new PowiainaNum(args[i]);
|
|
3269
3282
|
}
|
|
3270
3283
|
}
|
|
3271
3284
|
return max;
|
|
@@ -3497,7 +3510,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3497
3510
|
var x = new PowiainaNum(NaN);
|
|
3498
3511
|
// Judge the string was a number
|
|
3499
3512
|
if (input.startsWith("PN")) input = input.substring(2);
|
|
3500
|
-
if (input == "NaN") return PowiainaNum.NaN
|
|
3513
|
+
if (input == "NaN") return PowiainaNum.NaN;
|
|
3501
3514
|
if (!PowiainaNum.vanilla) {
|
|
3502
3515
|
input = input.replace(/J\^(\d+)/g, "(10{!})^$1");
|
|
3503
3516
|
input = input.replace(/J/g, "10{!}");
|
|
@@ -3782,7 +3795,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3782
3795
|
key: "grahalFunction",
|
|
3783
3796
|
value: function grahalFunction(layers2) {
|
|
3784
3797
|
var layers = new PowiainaNum(layers2);
|
|
3785
|
-
if (!layers.isInt() || layers.lt(0) || layers.isNaN()) return PowiainaNum.NaN
|
|
3798
|
+
if (!layers.isInt() || layers.lt(0) || layers.isNaN()) return PowiainaNum.NaN;
|
|
3786
3799
|
if (layers.eq(1)) return new PowiainaNum("10^^^(10^)^7625597484984 3638334640023.7783");else if (layers.lte(MSI)) {
|
|
3787
3800
|
return new PowiainaNum("(10{!})^".concat(layers.toNumber(), " 10^^^(10^)^7625597484984 3638334640023.7783"));
|
|
3788
3801
|
} else {
|
|
@@ -3796,12 +3809,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
3796
3809
|
* Zero
|
|
3797
3810
|
*/
|
|
3798
3811
|
PowiainaNum.ZERO = new PowiainaNum({
|
|
3799
|
-
array:
|
|
3800
|
-
arrow: 0,
|
|
3801
|
-
expans: 1,
|
|
3802
|
-
megota: 1,
|
|
3803
|
-
repeat: Infinity
|
|
3804
|
-
}],
|
|
3812
|
+
array: arrays.ZERO,
|
|
3805
3813
|
small: true,
|
|
3806
3814
|
layer: 0,
|
|
3807
3815
|
sign: 0
|