powiaina_num.js 0.2.12 → 0.2.13
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 +640 -298
- package/dist/PowiainaNum.esm.js +640 -298
- package/dist/PowiainaNum.js +640 -298
- package/dist/PowiainaNum.min.js +1 -1
- package/dist/index.d.ts +76 -18
- package/package.json +1 -1
package/dist/PowiainaNum.cjs.js
CHANGED
|
@@ -66,6 +66,8 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
66
66
|
|
|
67
67
|
/* Author: VeryrrDefine 0.2.0-beta.1.1*/
|
|
68
68
|
var _a;
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region constants
|
|
69
71
|
var powiainaNumError = "[PowiainaNum 0.2 error]";
|
|
70
72
|
var MSI = 9007199254740991;
|
|
71
73
|
var MSI_LOG10 = 15.954589770191003;
|
|
@@ -73,6 +75,8 @@ var MSI_REC = 1.1102230246251568e-16;
|
|
|
73
75
|
var LONG_STRING_MIN_LENGTH = 17;
|
|
74
76
|
var EXP_E_REC = 1.444667861009766;
|
|
75
77
|
var isPowiainaNum = /^(PN)?[\/\-\+]*(Infinity|NaN|(P+|P\^\d+ )?(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+))$/;
|
|
78
|
+
var BE_REGEX = /^((\d+(\.\d*)?|\d*\.\d+)?([EeFf]([-\+]?)))*(0|\d+(\.\d*)?|\d*\.\d+)$/;
|
|
79
|
+
//#endregion
|
|
76
80
|
//#region some useful functions
|
|
77
81
|
function newOperator(r) {
|
|
78
82
|
var a = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
@@ -86,6 +90,29 @@ function newOperator(r) {
|
|
|
86
90
|
valuereplaced: a == Infinity ? 0 : e == Infinity ? 1 : -1
|
|
87
91
|
};
|
|
88
92
|
}
|
|
93
|
+
function removeCommasOutsideBraces(input) {
|
|
94
|
+
var result = "";
|
|
95
|
+
var inBraces = false;
|
|
96
|
+
for (var i = 0; i < input.length; i++) {
|
|
97
|
+
var _char = input[i];
|
|
98
|
+
if (_char === "{") {
|
|
99
|
+
inBraces = true;
|
|
100
|
+
result += _char;
|
|
101
|
+
} else if (_char === "}") {
|
|
102
|
+
inBraces = false;
|
|
103
|
+
result += _char;
|
|
104
|
+
} else if (_char === ",") {
|
|
105
|
+
// 只有在花括号内部才保留逗号
|
|
106
|
+
if (inBraces) {
|
|
107
|
+
result += _char;
|
|
108
|
+
}
|
|
109
|
+
// 如果在花括号外部,就不添加到结果中(相当于删除)
|
|
110
|
+
} else {
|
|
111
|
+
result += _char;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
89
116
|
// parse 0.1.x PowiainaNum.js string
|
|
90
117
|
function parseLegacyPowiainaNumString(str) {
|
|
91
118
|
var pattern = /l(\d+)\s+s(\d+)\s+a(\[.*\])/;
|
|
@@ -118,7 +145,7 @@ function compareTuples() {
|
|
|
118
145
|
function replaceETo10(str) {
|
|
119
146
|
// 使用正则表达式匹配 (e^数字) 的模式
|
|
120
147
|
// 正则解释:\(e\^(\d+)\) 匹配 (e^数字),其中 \d+ 匹配一个或多个数字
|
|
121
|
-
return str.replace(/\(e\^(\d+)\)/g, "(10^)^$1 ").replace(/(\d+)
|
|
148
|
+
return str.replace(/\(e\^(\d+)\)/g, "(10^)^$1 ").replace(/(\d+)[Pp][Tt]/g, "(10^)^$1 ");
|
|
122
149
|
}
|
|
123
150
|
/**
|
|
124
151
|
* 把一个字符串很长的数进行以10为底的对数
|
|
@@ -172,8 +199,10 @@ var OMEGA = 0.56714329040978387299997; // W(1, 0)
|
|
|
172
199
|
// The evaluation can become inaccurate very close to the branch point
|
|
173
200
|
// Evaluates W(x, 0) if principal is true, W(x, -1) if principal is false
|
|
174
201
|
function f_lambertw(z) {
|
|
175
|
-
var
|
|
176
|
-
var
|
|
202
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e-10;
|
|
203
|
+
var pr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
204
|
+
var tol = t;
|
|
205
|
+
var principal = pr;
|
|
177
206
|
var w;
|
|
178
207
|
var wn;
|
|
179
208
|
if (!Number.isFinite(z)) {
|
|
@@ -336,16 +365,26 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
336
365
|
this.small = false;
|
|
337
366
|
this.sign = 0;
|
|
338
367
|
this.layer = 0;
|
|
339
|
-
if (
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
368
|
+
if (PowiainaNum.blankArgumentConstructorReturnZero) {
|
|
369
|
+
this.resetFromObject(PowiainaNum.ZERO);
|
|
370
|
+
}
|
|
371
|
+
try {
|
|
372
|
+
if (typeof arg1 == "undefined") {} else if (typeof arg1 == "number") {
|
|
373
|
+
var obj = PowiainaNum.fromNumber(arg1);
|
|
374
|
+
this.resetFromObject(obj);
|
|
375
|
+
} else if (_typeof(arg1) == "object") {
|
|
376
|
+
var _obj = PowiainaNum.fromObject(arg1);
|
|
377
|
+
this.resetFromObject(_obj);
|
|
378
|
+
} else if (typeof arg1 == "string") {
|
|
379
|
+
var _obj2 = PowiainaNum.fromString(arg1);
|
|
380
|
+
this.resetFromObject(_obj2);
|
|
381
|
+
} else {
|
|
382
|
+
var isn = arg1;
|
|
383
|
+
}
|
|
384
|
+
} catch (e) {
|
|
385
|
+
console.error("Malformed input");
|
|
386
|
+
console.error(e);
|
|
387
|
+
}
|
|
349
388
|
}
|
|
350
389
|
//#region 4 Basic calculates.
|
|
351
390
|
/**
|
|
@@ -356,7 +395,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
356
395
|
key: "add",
|
|
357
396
|
value: function add(other) {
|
|
358
397
|
var _b, _c, _d, _e;
|
|
359
|
-
var x = this.clone();
|
|
398
|
+
var x = this.clone().normalize();
|
|
360
399
|
var y = new PowiainaNum(other);
|
|
361
400
|
// inf + -inf = nan
|
|
362
401
|
if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY)) return PowiainaNum.NaN.clone();
|
|
@@ -399,40 +438,56 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
399
438
|
if (isFinite(temp) && temp !== 0) {
|
|
400
439
|
return PowiainaNum.fromNumber(temp);
|
|
401
440
|
}
|
|
402
|
-
var
|
|
441
|
+
var signMult = 1;
|
|
442
|
+
/**Calculate numbers [1, 9e15] (useless) */
|
|
403
443
|
if (!a.small && !b.small && !((_b = a.array[1]) === null || _b === void 0 ? void 0 : _b.repeat) && !((_c = b.array[1]) === null || _c === void 0 ? void 0 : _c.repeat) && a.sign == b.sign) {
|
|
404
444
|
return new PowiainaNum((a.array[0].repeat + b.array[0].repeat) * a.sign);
|
|
405
445
|
}
|
|
446
|
+
// Calculate a & b's 10-logarithm
|
|
406
447
|
var alog10 = (a.small ? -1 : 1) * (((_d = a.array[1]) === null || _d === void 0 ? void 0 : _d.repeat) ? a.array[0].repeat : Math.log10(a.array[0].repeat));
|
|
407
448
|
var blog10 = (b.small ? -1 : 1) * (((_e = b.array[1]) === null || _e === void 0 ? void 0 : _e.repeat) ? b.array[0].repeat : Math.log10(b.array[0].repeat));
|
|
408
449
|
if (alog10 - blog10 > MSI_LOG10) return a;
|
|
450
|
+
/**
|
|
451
|
+
* Offset, a number can make 10^ a+off calculatable not very small or big
|
|
452
|
+
*/
|
|
409
453
|
var offset = -Math.floor(alog10); //a number can make a+off in [0,1)
|
|
410
|
-
var
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
if (
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
if (
|
|
423
|
-
|
|
454
|
+
var resultLogarithm = 0;
|
|
455
|
+
/** 10^(a+off) + 10^(b+off). */
|
|
456
|
+
var offsetedResult = a.sign * Math.pow(10, alog10 + offset) + b.sign * Math.pow(10, blog10 + offset);
|
|
457
|
+
if (offsetedResult > 0) resultLogarithm = Math.log10(offsetedResult) - offset;
|
|
458
|
+
if (offsetedResult < 0) {
|
|
459
|
+
resultLogarithm = Math.log10(-offsetedResult) - offset;
|
|
460
|
+
signMult *= -1;
|
|
461
|
+
}
|
|
462
|
+
if (offsetedResult == 0) return PowiainaNum.ZERO.clone();
|
|
463
|
+
var resultPN = PowiainaNum.NaN.clone();
|
|
464
|
+
resultPN.sign = 1;
|
|
465
|
+
/** abs(resultLogarithm) > 15.9, use 10^x form. */
|
|
466
|
+
if (resultLogarithm > MSI_LOG10 || resultLogarithm < -MSI_LOG10) {
|
|
467
|
+
resultPN.array = [newOperator(resultLogarithm, 0), newOperator(1, 1)];
|
|
468
|
+
/**otherwise, use 10** abs(resultLogarithm) */
|
|
424
469
|
} else {
|
|
425
|
-
|
|
470
|
+
resultPN.array = [newOperator(Math.pow(10, Math.abs(resultLogarithm)), 0)];
|
|
426
471
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
return
|
|
472
|
+
resultPN.small = resultLogarithm < 0 ? true : false;
|
|
473
|
+
resultPN.sign *= signMult;
|
|
474
|
+
return resultPN;
|
|
475
|
+
}
|
|
476
|
+
}, {
|
|
477
|
+
key: "plus",
|
|
478
|
+
value: function plus(other) {
|
|
479
|
+
return this.add(other);
|
|
430
480
|
}
|
|
431
481
|
}, {
|
|
432
482
|
key: "sub",
|
|
433
483
|
value: function sub(a) {
|
|
434
484
|
return this.add(new PowiainaNum(a).neg());
|
|
435
485
|
}
|
|
486
|
+
}, {
|
|
487
|
+
key: "minus",
|
|
488
|
+
value: function minus(other) {
|
|
489
|
+
return this.sub(other);
|
|
490
|
+
}
|
|
436
491
|
}, {
|
|
437
492
|
key: "mul",
|
|
438
493
|
value: function mul(other) {
|
|
@@ -466,12 +521,22 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
466
521
|
r.sign = x.sign * y.sign;
|
|
467
522
|
return r;
|
|
468
523
|
}
|
|
524
|
+
}, {
|
|
525
|
+
key: "times",
|
|
526
|
+
value: function times(other) {
|
|
527
|
+
return this.mul(other);
|
|
528
|
+
}
|
|
469
529
|
}, {
|
|
470
530
|
key: "div",
|
|
471
531
|
value: function div(other) {
|
|
472
532
|
var x = new PowiainaNum(other).rec();
|
|
473
533
|
return this.mul(x);
|
|
474
534
|
}
|
|
535
|
+
}, {
|
|
536
|
+
key: "divide",
|
|
537
|
+
value: function divide(other) {
|
|
538
|
+
return this.div(other);
|
|
539
|
+
}
|
|
475
540
|
}, {
|
|
476
541
|
key: "mod",
|
|
477
542
|
value: function mod(x) {
|
|
@@ -479,34 +544,45 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
479
544
|
var division = this.div(other);
|
|
480
545
|
return division.sub(division.floor()).mul(other);
|
|
481
546
|
}
|
|
547
|
+
}, {
|
|
548
|
+
key: "modulus",
|
|
549
|
+
value: function modulus(x) {
|
|
550
|
+
return this.mod(x);
|
|
551
|
+
}
|
|
552
|
+
}, {
|
|
553
|
+
key: "pow10",
|
|
554
|
+
value:
|
|
482
555
|
//#endregion
|
|
483
556
|
//#region power
|
|
484
557
|
/**
|
|
485
558
|
* @returns 10 to the power of `this`
|
|
486
559
|
*/
|
|
487
|
-
|
|
488
|
-
key: "pow10",
|
|
489
|
-
value: function pow10() {
|
|
560
|
+
function pow10() {
|
|
490
561
|
var _b, _c;
|
|
491
|
-
var
|
|
562
|
+
var thisObject = this.clone();
|
|
492
563
|
// inf & nan check
|
|
493
564
|
if (!this.isFinite()) return this.clone();
|
|
494
|
-
|
|
565
|
+
/** when 10^(t), t<0, use 10^(-t) reciprocate. */
|
|
566
|
+
if (thisObject.isneg()) {
|
|
495
567
|
// 10^(-x) = 1/(10^x)
|
|
496
|
-
|
|
497
|
-
return
|
|
568
|
+
thisObject.sign *= -1;
|
|
569
|
+
return thisObject.pow10().rec();
|
|
498
570
|
}
|
|
499
|
-
if
|
|
500
|
-
|
|
571
|
+
/**if t lessthan log10 2^1024, use fromNumber. */
|
|
572
|
+
if (thisObject.lte(308.25471555991675)) {
|
|
573
|
+
return PowiainaNum.fromNumber(Math.pow(10, thisObject.toNumber()));
|
|
501
574
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
575
|
+
/**calculate directly */
|
|
576
|
+
if (thisObject.small) {
|
|
577
|
+
if (thisObject.lt(PowiainaNum.MSI_REC)) return PowiainaNum.ONE;
|
|
578
|
+
return new PowiainaNum(Math.pow(10, Math.pow(thisObject.array[0].repeat, -1)));
|
|
505
579
|
}
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
580
|
+
/** indistinguishable above 10^^9e15 */
|
|
581
|
+
if (thisObject.gt(PowiainaNum.TETRATED_MSI)) return thisObject;
|
|
582
|
+
/**otherwise add 10^ directly */
|
|
583
|
+
thisObject.setOperator(((_c = (_b = thisObject.array[1]) === null || _b === void 0 ? void 0 : _b.repeat) !== null && _c !== void 0 ? _c : 0) + 1, 1);
|
|
584
|
+
thisObject.normalize();
|
|
585
|
+
return thisObject;
|
|
510
586
|
}
|
|
511
587
|
}, {
|
|
512
588
|
key: "pow",
|
|
@@ -516,8 +592,16 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
516
592
|
if (!other.isFinite()) return other.clone();
|
|
517
593
|
if (!this.isFinite()) return this.clone();
|
|
518
594
|
if (this.eq(10)) return other.pow10();
|
|
595
|
+
if (other.isneg()) return this.pow(other.neg()).rec();
|
|
519
596
|
if (this.isneg()) {
|
|
520
|
-
if (!other.isInt())
|
|
597
|
+
if (!other.isInt()) {
|
|
598
|
+
if (other.small) {
|
|
599
|
+
if (other.rec().div(2).eq(1)) {
|
|
600
|
+
return this.neg().pow(other).neg();
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return PowiainaNum.NaN.clone();
|
|
604
|
+
}
|
|
521
605
|
var r = this.abs().pow(other);
|
|
522
606
|
r.sign = function () {
|
|
523
607
|
var a = other.mod(2).round();
|
|
@@ -594,6 +678,16 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
594
678
|
var other = new PowiainaNum(base);
|
|
595
679
|
return this.log10().div(other.log10());
|
|
596
680
|
}
|
|
681
|
+
}, {
|
|
682
|
+
key: "log2",
|
|
683
|
+
value: function log2() {
|
|
684
|
+
return this.log(2);
|
|
685
|
+
}
|
|
686
|
+
}, {
|
|
687
|
+
key: "logBase",
|
|
688
|
+
value: function logBase(a) {
|
|
689
|
+
return this.log(a);
|
|
690
|
+
}
|
|
597
691
|
}, {
|
|
598
692
|
key: "ln",
|
|
599
693
|
value: function ln() {
|
|
@@ -701,7 +795,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
701
795
|
//Code from break_eternity.js
|
|
702
796
|
//Some special values, for testing: https://en.wikipedia.org/wiki/Lambert_W_function#Special_values
|
|
703
797
|
function lambertw() {
|
|
704
|
-
var
|
|
798
|
+
var princ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
799
|
+
var principal = princ;
|
|
705
800
|
if (this.lt(-0.3678794411710499)) {
|
|
706
801
|
return PowiainaNum.NaN.clone(); //complex
|
|
707
802
|
} else if (principal) {
|
|
@@ -716,12 +811,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
716
811
|
return this.log();
|
|
717
812
|
}
|
|
718
813
|
} else {
|
|
719
|
-
if (this.sign === 1) {
|
|
814
|
+
if (this.sign === -1) {
|
|
720
815
|
return PowiainaNum.NaN.clone(); //complex
|
|
721
816
|
}
|
|
722
|
-
if (this.
|
|
817
|
+
if (this.lt(9e15)) {
|
|
723
818
|
return PowiainaNum.fromNumber(f_lambertw(this.sign * this.array[0].repeat, 1e-10, false));
|
|
724
|
-
} else if (this.
|
|
819
|
+
} else if (this.lt(PowiainaNum.E_MSI)) {
|
|
725
820
|
return d_lambertw(this, 1e-10, false);
|
|
726
821
|
} else {
|
|
727
822
|
return this.neg().rec().lambertw().neg();
|
|
@@ -742,7 +837,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
742
837
|
var payl = new PowiainaNum(payload);
|
|
743
838
|
if (t.isNaN() || other.isNaN() || payl.isNaN()) return PowiainaNum.NaN.clone();
|
|
744
839
|
if (t.eq(1)) return PowiainaNum.ONE.clone();
|
|
745
|
-
if (payl.neq(PowiainaNum.ONE)
|
|
840
|
+
if (payl.neq(PowiainaNum.ONE) && t.gte(EXP_E_REC)) {
|
|
841
|
+
other = other.add(payl.slog(t));
|
|
842
|
+
}
|
|
746
843
|
var negln;
|
|
747
844
|
if (other.isInfi() && other.sign > 0) {
|
|
748
845
|
if (t.gte(EXP_E_REC)) return PowiainaNum.POSITIVE_INFINITY.clone();
|
|
@@ -1072,9 +1169,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1072
1169
|
// base^base^... = x? (? bases)
|
|
1073
1170
|
var r = 0;
|
|
1074
1171
|
// 计算x与base的差距
|
|
1075
|
-
var
|
|
1076
|
-
if (
|
|
1077
|
-
var l =
|
|
1172
|
+
var distanceLayerOf = x.getOperator(arrowsNum) - b.getOperator(arrowsNum);
|
|
1173
|
+
if (distanceLayerOf > 3) {
|
|
1174
|
+
var l = distanceLayerOf - 3;
|
|
1078
1175
|
r += l;
|
|
1079
1176
|
x.setOperator(x.getOperator(arrowsNum) - l, arrowsNum);
|
|
1080
1177
|
}
|
|
@@ -1116,18 +1213,18 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1116
1213
|
}
|
|
1117
1214
|
}, {
|
|
1118
1215
|
key: "pentate",
|
|
1119
|
-
value: function pentate(other) {
|
|
1120
|
-
return this.arrow(3)(other);
|
|
1216
|
+
value: function pentate(other, payload) {
|
|
1217
|
+
return this.arrow(3)(other, payload);
|
|
1121
1218
|
}
|
|
1122
1219
|
}, {
|
|
1123
1220
|
key: "hexate",
|
|
1124
|
-
value: function hexate(other) {
|
|
1125
|
-
return this.arrow(4)(other);
|
|
1221
|
+
value: function hexate(other, payload) {
|
|
1222
|
+
return this.arrow(4)(other, payload);
|
|
1126
1223
|
}
|
|
1127
1224
|
}, {
|
|
1128
1225
|
key: "pent",
|
|
1129
|
-
value: function pent(other) {
|
|
1130
|
-
return this.arrow(3)(other);
|
|
1226
|
+
value: function pent(other, payload) {
|
|
1227
|
+
return this.arrow(3)(other, payload);
|
|
1131
1228
|
}
|
|
1132
1229
|
}, {
|
|
1133
1230
|
key: "penta_log",
|
|
@@ -1135,6 +1232,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1135
1232
|
var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1136
1233
|
return this.anyarrow_log(3)(base);
|
|
1137
1234
|
}
|
|
1235
|
+
}, {
|
|
1236
|
+
key: "expansion",
|
|
1237
|
+
value:
|
|
1138
1238
|
/**
|
|
1139
1239
|
* Expansion, which is `this`{{1}}`other2`.
|
|
1140
1240
|
*
|
|
@@ -1142,9 +1242,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1142
1242
|
*
|
|
1143
1243
|
* @url https://googology.fandom.com/wiki/Expansion
|
|
1144
1244
|
*/
|
|
1145
|
-
|
|
1146
|
-
key: "expansion",
|
|
1147
|
-
value: function expansion(other2) {
|
|
1245
|
+
function expansion(other2) {
|
|
1148
1246
|
var other = new PowiainaNum(other2);
|
|
1149
1247
|
var t = this.clone();
|
|
1150
1248
|
if (other.lt(PowiainaNum.ZERO) || !other.isInt()) return PowiainaNum.NaN.clone();
|
|
@@ -1392,6 +1490,11 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1392
1490
|
var other = new PowiainaNum(x).abs();
|
|
1393
1491
|
return this.abs().cmp(other);
|
|
1394
1492
|
}
|
|
1493
|
+
/**
|
|
1494
|
+
* -1: `this` is smaller
|
|
1495
|
+
* 0: equals
|
|
1496
|
+
* 1: `x` is bigger
|
|
1497
|
+
*/
|
|
1395
1498
|
}, {
|
|
1396
1499
|
key: "compare",
|
|
1397
1500
|
value: function compare(x) {
|
|
@@ -1410,6 +1513,14 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1410
1513
|
for (var i = 0; this.array.length - 1 - i >= 0 && other.array.length - 1 - i >= 0; i++) {
|
|
1411
1514
|
var op1 = this.array[this.array.length - 1 - i];
|
|
1412
1515
|
var op2 = other.array[other.array.length - 1 - i];
|
|
1516
|
+
if (op1.repeat === Infinity) {
|
|
1517
|
+
result = 1;
|
|
1518
|
+
break;
|
|
1519
|
+
}
|
|
1520
|
+
if (op2.repeat === Infinity) {
|
|
1521
|
+
result = -1;
|
|
1522
|
+
break;
|
|
1523
|
+
}
|
|
1413
1524
|
var cmp = compareTuples([op1.megota, op1.expans, op1.arrow, op1.repeat], [op2.megota, op2.expans, op2.arrow, op2.repeat]);
|
|
1414
1525
|
if (cmp == 1) {
|
|
1415
1526
|
result = 1;
|
|
@@ -1457,6 +1568,16 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1457
1568
|
var t = this.cmp(other);
|
|
1458
1569
|
return t == 0 || t == 1;
|
|
1459
1570
|
}
|
|
1571
|
+
}, {
|
|
1572
|
+
key: "equals",
|
|
1573
|
+
value: function equals(other) {
|
|
1574
|
+
return this.eq(other);
|
|
1575
|
+
}
|
|
1576
|
+
}, {
|
|
1577
|
+
key: "notEquals",
|
|
1578
|
+
value: function notEquals(other) {
|
|
1579
|
+
return this.neq(other);
|
|
1580
|
+
}
|
|
1460
1581
|
}, {
|
|
1461
1582
|
key: "eq_tolerance",
|
|
1462
1583
|
value: function eq_tolerance(value) {
|
|
@@ -1466,6 +1587,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1466
1587
|
}
|
|
1467
1588
|
//#endregion
|
|
1468
1589
|
//#region geometry
|
|
1590
|
+
/**this function is indistinguishable above 4503599627370496*/
|
|
1469
1591
|
}, {
|
|
1470
1592
|
key: "sin",
|
|
1471
1593
|
value: function sin() {
|
|
@@ -1518,6 +1640,16 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1518
1640
|
a.small = !a.small;
|
|
1519
1641
|
return a;
|
|
1520
1642
|
}
|
|
1643
|
+
}, {
|
|
1644
|
+
key: "recip",
|
|
1645
|
+
value: function recip() {
|
|
1646
|
+
return this.rec();
|
|
1647
|
+
}
|
|
1648
|
+
}, {
|
|
1649
|
+
key: "reciprocate",
|
|
1650
|
+
value: function reciprocate() {
|
|
1651
|
+
return this.rec();
|
|
1652
|
+
}
|
|
1521
1653
|
}, {
|
|
1522
1654
|
key: "floor",
|
|
1523
1655
|
value: function floor() {
|
|
@@ -1558,6 +1690,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1558
1690
|
r.sign = this.sign;
|
|
1559
1691
|
return r;
|
|
1560
1692
|
}
|
|
1693
|
+
}, {
|
|
1694
|
+
key: "trunc",
|
|
1695
|
+
value:
|
|
1561
1696
|
/**
|
|
1562
1697
|
* Work like `Math.trunc`,
|
|
1563
1698
|
*
|
|
@@ -1570,15 +1705,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1570
1705
|
* new PowiainaNum(-1.114514).trunc() == new PowiainaNum(-1)
|
|
1571
1706
|
* @returns
|
|
1572
1707
|
*/
|
|
1573
|
-
|
|
1574
|
-
key: "trunc",
|
|
1575
|
-
value: function trunc() {
|
|
1708
|
+
function trunc() {
|
|
1576
1709
|
var y = this.clone();
|
|
1577
1710
|
return y.gte(0) ? y.floor() : y.ceil();
|
|
1578
1711
|
}
|
|
1579
|
-
/**
|
|
1580
|
-
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
1581
|
-
*/
|
|
1582
1712
|
}, {
|
|
1583
1713
|
key: "isNaN",
|
|
1584
1714
|
value: function (_isNaN) {
|
|
@@ -1641,10 +1771,164 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1641
1771
|
value: function isneg() {
|
|
1642
1772
|
return this.sign < 0;
|
|
1643
1773
|
}
|
|
1774
|
+
}, {
|
|
1775
|
+
key: "getOperatorIndex",
|
|
1776
|
+
value:
|
|
1777
|
+
//#endregion
|
|
1778
|
+
//#region operators
|
|
1779
|
+
/**
|
|
1780
|
+
* @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.
|
|
1781
|
+
*/
|
|
1782
|
+
function getOperatorIndex(arrow) {
|
|
1783
|
+
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1784
|
+
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1785
|
+
for (var i = 0; i < this.array.length; i++) {
|
|
1786
|
+
var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
|
|
1787
|
+
if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
|
|
1788
|
+
if (cmp == 1) return i - 0.5; // It's between [xx, xx,xx*,?,*xx]!
|
|
1789
|
+
}
|
|
1790
|
+
return this.array.length - 0.5;
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* @returns number repeats of operators with given arguments.
|
|
1794
|
+
*/
|
|
1795
|
+
}, {
|
|
1796
|
+
key: "getOperator",
|
|
1797
|
+
value: function getOperator(arrow) {
|
|
1798
|
+
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1799
|
+
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1800
|
+
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1801
|
+
if (!this.array[index]) return 0;
|
|
1802
|
+
return this.array[index].repeat;
|
|
1803
|
+
}
|
|
1804
|
+
/**
|
|
1805
|
+
* Modify the repeat of operator
|
|
1806
|
+
* @param number val the repeat of operator will modify to array.
|
|
1807
|
+
* @returns bool Is the operators array changed?
|
|
1808
|
+
*/
|
|
1809
|
+
}, {
|
|
1810
|
+
key: "setOperator",
|
|
1811
|
+
value: function setOperator(val, arrow) {
|
|
1812
|
+
var expans = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1813
|
+
var megota = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
1814
|
+
// if (arrow!=0&&val==0) return false;
|
|
1815
|
+
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1816
|
+
if (!this.array[index]) {
|
|
1817
|
+
this.array.splice(Math.ceil(index), 0, {
|
|
1818
|
+
arrow: arrow,
|
|
1819
|
+
expans: expans,
|
|
1820
|
+
megota: megota,
|
|
1821
|
+
valuereplaced: expans === Infinity ? 1 : arrow == Infinity ? 0 : -1,
|
|
1822
|
+
repeat: val
|
|
1823
|
+
});
|
|
1824
|
+
return true;
|
|
1825
|
+
}
|
|
1826
|
+
this.array[index].repeat = val;
|
|
1827
|
+
// this.normalize()
|
|
1828
|
+
return false;
|
|
1829
|
+
}
|
|
1830
|
+
//#endregion
|
|
1831
|
+
//#region converters
|
|
1832
|
+
/**
|
|
1833
|
+
* Convert `this` to Javascript `number`
|
|
1834
|
+
*
|
|
1835
|
+
* returns `Infinity` when the number is greater than `Number.MAX_VALUE`
|
|
1836
|
+
*/
|
|
1837
|
+
}, {
|
|
1838
|
+
key: "toNumber",
|
|
1839
|
+
value: function toNumber() {
|
|
1840
|
+
if (this.sign == -1) return -this.neg().toNumber();
|
|
1841
|
+
if (this.small) return 1 / this.rec().toNumber();
|
|
1842
|
+
if (this.array.length > 2) return Infinity;
|
|
1843
|
+
if (this.array.length == 1) return this.array[0].repeat;else if (this.array.length == 2 && this.array[1].arrow == 1 && this.array[1].expans == 1 && this.array[1].megota == 1 && this.array[1].repeat == 1) return Math.pow(10, this.getOperator(0));
|
|
1844
|
+
return NaN;
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Convert `this` to a string
|
|
1848
|
+
*/
|
|
1849
|
+
}, {
|
|
1850
|
+
key: "toString_core",
|
|
1851
|
+
value: function toString_core() {
|
|
1852
|
+
if (this.isNaN()) return "NaN";
|
|
1853
|
+
if (this.sign == -1) return "-".concat(this.neg().toString());
|
|
1854
|
+
if (this.small) {
|
|
1855
|
+
if (this.isZero()) return "0";
|
|
1856
|
+
return "/".concat(this.rec().toString());
|
|
1857
|
+
}
|
|
1858
|
+
if (this.isInfi()) return "Infinity";
|
|
1859
|
+
// P^a (10{arrow,expans,megota})^repeation base
|
|
1860
|
+
var res = "";
|
|
1861
|
+
if (!this.layer) res += "";else if (this.layer < 3) res += "P".repeat(this.layer);else res += "P^" + this.layer + " ";
|
|
1862
|
+
for (var i = this.array.length - 1; i >= 0; i--) {
|
|
1863
|
+
var oper = this.array[i];
|
|
1864
|
+
var calc = "10{".concat(oper.arrow === Infinity ? "!" : oper.arrow).concat(oper.expans > 1 || oper.megota > 1 ? ",".concat(oper.expans === Infinity ? "!" : oper.expans) : "").concat(oper.megota > 1 ? ",".concat(oper.megota) : "", "}");
|
|
1865
|
+
if (oper.arrow == 1 && oper.expans == 1 && oper.megota == 1 && oper.repeat < 5) {
|
|
1866
|
+
calc = "e".repeat(oper.repeat);
|
|
1867
|
+
} else if (oper.arrow == 0 && oper.expans == 1 && oper.megota == 1) {
|
|
1868
|
+
calc = oper.repeat.toString();
|
|
1869
|
+
} else if (oper.repeat > 1) {
|
|
1870
|
+
calc = "(".concat(calc, ")^").concat(oper.repeat, " ");
|
|
1871
|
+
} else {
|
|
1872
|
+
calc = "".concat(calc);
|
|
1873
|
+
}
|
|
1874
|
+
res += "".concat(calc);
|
|
1875
|
+
}
|
|
1876
|
+
return res;
|
|
1877
|
+
}
|
|
1878
|
+
}, {
|
|
1879
|
+
key: "toString",
|
|
1880
|
+
value: function toString() {
|
|
1881
|
+
try {
|
|
1882
|
+
return this.toString_core();
|
|
1883
|
+
} catch (_b) {
|
|
1884
|
+
console.error("Checked error when converting to string");
|
|
1885
|
+
return "NaN";
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
}, {
|
|
1889
|
+
key: "toJSON",
|
|
1890
|
+
value:
|
|
1891
|
+
/**
|
|
1892
|
+
* Convert `this` to a JSON object
|
|
1893
|
+
* @returns a JSON object
|
|
1894
|
+
*/
|
|
1895
|
+
function toJSON() {
|
|
1896
|
+
return "PN" + this.toString();
|
|
1897
|
+
}
|
|
1898
|
+
}, {
|
|
1899
|
+
key: "arr01",
|
|
1900
|
+
get:
|
|
1901
|
+
/**
|
|
1902
|
+
* A property array value for version 0.1.x PowiainaNum.
|
|
1903
|
+
*/
|
|
1904
|
+
function get() {
|
|
1905
|
+
var res = [0];
|
|
1906
|
+
for (var i = 0; i < this.array.length; i++) {
|
|
1907
|
+
if (i == 0) res[0] = this.array[i].repeat;else {
|
|
1908
|
+
// @ts-ignore
|
|
1909
|
+
res[i] = [0, 0, 0, 0];
|
|
1910
|
+
// @ts-ignore
|
|
1911
|
+
res[i][0] = this.array[i].arrow == Infinity ? "x" : this.array[i].arrow;
|
|
1912
|
+
// @ts-ignore
|
|
1913
|
+
res[i][1] = this.array[i].repeat;
|
|
1914
|
+
// @ts-ignore
|
|
1915
|
+
res[i][2] = this.array[i].expans == Infinity ? "x" : this.array[i].expans;
|
|
1916
|
+
// @ts-ignore
|
|
1917
|
+
res[i][3] = this.array[i].megota;
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
return res;
|
|
1921
|
+
}
|
|
1922
|
+
//#endregion
|
|
1923
|
+
//#region useless functions
|
|
1924
|
+
/**
|
|
1925
|
+
* This function is for NaNe308, if you want to calculate G(x), use this function directly.
|
|
1926
|
+
*/
|
|
1644
1927
|
}, {
|
|
1645
1928
|
key: "normalize",
|
|
1646
1929
|
value:
|
|
1647
1930
|
//#endregion
|
|
1931
|
+
//#region other functions
|
|
1648
1932
|
/**
|
|
1649
1933
|
* Normalize functions will make this number convert into standard format.(it also change `this`, like [].sort)
|
|
1650
1934
|
* @returns normalized number
|
|
@@ -1653,9 +1937,14 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1653
1937
|
//TODO: normalize
|
|
1654
1938
|
var renormalize = true;
|
|
1655
1939
|
var x = this;
|
|
1656
|
-
|
|
1940
|
+
if (this.array === undefined) {
|
|
1941
|
+
x.array = [newOperator(NaN, 0, 1, 1)];
|
|
1942
|
+
}
|
|
1943
|
+
if (this.sign === undefined) this.sign = 0;
|
|
1944
|
+
if (this.layer === undefined) this.layer = 0;
|
|
1945
|
+
for (var i = 0; i < this.array.length; i++) {
|
|
1657
1946
|
// Check what is infinity
|
|
1658
|
-
if (this.array[
|
|
1947
|
+
if (this.array[i].repeat == Infinity) {
|
|
1659
1948
|
this.array = [{
|
|
1660
1949
|
arrow: 0,
|
|
1661
1950
|
expans: 1,
|
|
@@ -1666,8 +1955,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1666
1955
|
return this;
|
|
1667
1956
|
}
|
|
1668
1957
|
}
|
|
1669
|
-
for (var
|
|
1670
|
-
var e = x.array[
|
|
1958
|
+
for (var _i = 1; _i < x.array.length; ++_i) {
|
|
1959
|
+
var e = x.array[_i];
|
|
1671
1960
|
if (e.arrow === null || e.arrow === undefined) {
|
|
1672
1961
|
e.arrow = 0;
|
|
1673
1962
|
}
|
|
@@ -1698,28 +1987,28 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1698
1987
|
renormalize = false;
|
|
1699
1988
|
// Sort arrays.
|
|
1700
1989
|
this.array.sort(arraySortFunction);
|
|
1701
|
-
for (
|
|
1702
|
-
if (x.array[
|
|
1990
|
+
for (var _i2 = 1; _i2 < x.array.length - 1; ++_i2) {
|
|
1991
|
+
if (x.array[_i2].arrow == x.array[_i2 + 1].arrow && x.array[_i2].expans == x.array[_i2 + 1].expans && x.array[_i2].megota == x.array[_i2 + 1].megota) {
|
|
1703
1992
|
// same array's merge
|
|
1704
|
-
x.array[
|
|
1705
|
-
x.array.splice(
|
|
1706
|
-
--
|
|
1993
|
+
x.array[_i2].repeat += x.array[_i2 + 1].repeat;
|
|
1994
|
+
x.array.splice(_i2 + 1, 1);
|
|
1995
|
+
--_i2;
|
|
1707
1996
|
renormalize = true;
|
|
1708
1997
|
}
|
|
1709
1998
|
}
|
|
1710
|
-
for (
|
|
1999
|
+
for (var _i3 = 1; _i3 < x.array.length; ++_i3) {
|
|
1711
2000
|
// If there is a 0 repeat operator, remove it.
|
|
1712
|
-
if (x.array[
|
|
1713
|
-
x.array.splice(
|
|
1714
|
-
--
|
|
2001
|
+
if (x.array[_i3].arrow !== 0 && (x.array[_i3].repeat === 0 || x.array[_i3].repeat === null || x.array[_i3].repeat === undefined)) {
|
|
2002
|
+
x.array.splice(_i3, 1);
|
|
2003
|
+
--_i3;
|
|
1715
2004
|
continue;
|
|
1716
2005
|
}
|
|
1717
2006
|
// If there is a operator which arrow 0 and brace count >=2
|
|
1718
2007
|
// replace it as arrow replacement operaotr
|
|
1719
|
-
if (x.array[
|
|
1720
|
-
x.array[
|
|
1721
|
-
x.array[
|
|
1722
|
-
x.array[
|
|
2008
|
+
if (x.array[_i3].arrow == 0 && x.array[_i3].expans >= 2) {
|
|
2009
|
+
x.array[_i3].arrow = Infinity;
|
|
2010
|
+
x.array[_i3].valuereplaced = 0;
|
|
2011
|
+
x.array[_i3].expans = x.array[_i3].expans - 1;
|
|
1723
2012
|
}
|
|
1724
2013
|
}
|
|
1725
2014
|
if (x.array.length > PowiainaNum.maxOps) x.array.splice(1, x.array.length - PowiainaNum.maxOps); // max operators check
|
|
@@ -1749,6 +2038,11 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1749
2038
|
this.small = !this.small;
|
|
1750
2039
|
renormalize = true;
|
|
1751
2040
|
}
|
|
2041
|
+
// for a = 1, small should false.
|
|
2042
|
+
if (this.array.length == 1 && this.array[0].repeat == 1 && this.small) {
|
|
2043
|
+
this.small = false;
|
|
2044
|
+
renormalize = true;
|
|
2045
|
+
}
|
|
1752
2046
|
// for any 10{X>9e15}10, replace into 10{!}X;
|
|
1753
2047
|
if (this.array.length >= 2 && this.array[1].arrow >= MSI) {
|
|
1754
2048
|
this.array[0].repeat = this.array[1].arrow;
|
|
@@ -1804,61 +2098,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1804
2098
|
} while (renormalize);
|
|
1805
2099
|
return this;
|
|
1806
2100
|
}
|
|
1807
|
-
//#region operators
|
|
1808
|
-
/**
|
|
1809
|
-
* @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.
|
|
1810
|
-
*/
|
|
1811
|
-
}, {
|
|
1812
|
-
key: "getOperatorIndex",
|
|
1813
|
-
value: function getOperatorIndex(arrow) {
|
|
1814
|
-
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1815
|
-
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1816
|
-
for (var i = 0; i < this.array.length; i++) {
|
|
1817
|
-
var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
|
|
1818
|
-
if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
|
|
1819
|
-
if (cmp == 1) return i - 0.5; // It's between [xx, xx,xx*,?,*xx]!
|
|
1820
|
-
}
|
|
1821
|
-
return this.array.length - 0.5;
|
|
1822
|
-
}
|
|
1823
|
-
/**
|
|
1824
|
-
* @returns number repeats of operators with given arguments.
|
|
1825
|
-
*/
|
|
1826
|
-
}, {
|
|
1827
|
-
key: "getOperator",
|
|
1828
|
-
value: function getOperator(arrow) {
|
|
1829
|
-
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1830
|
-
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1831
|
-
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1832
|
-
if (!this.array[index]) return 0;
|
|
1833
|
-
return this.array[index].repeat;
|
|
1834
|
-
}
|
|
1835
|
-
/**
|
|
1836
|
-
* Modify the repeat of operator
|
|
1837
|
-
* @param number val the repeat of operator will modify to array.
|
|
1838
|
-
* @returns bool Is the operators array changed?
|
|
1839
|
-
*/
|
|
1840
|
-
}, {
|
|
1841
|
-
key: "setOperator",
|
|
1842
|
-
value: function setOperator(val, arrow) {
|
|
1843
|
-
var expans = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1844
|
-
var megota = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
1845
|
-
// if (arrow!=0&&val==0) return false;
|
|
1846
|
-
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1847
|
-
if (!this.array[index]) {
|
|
1848
|
-
this.array.splice(Math.ceil(index), 0, {
|
|
1849
|
-
arrow: arrow,
|
|
1850
|
-
expans: expans,
|
|
1851
|
-
megota: megota,
|
|
1852
|
-
valuereplaced: expans === Infinity ? 1 : arrow == Infinity ? 0 : -1,
|
|
1853
|
-
repeat: val
|
|
1854
|
-
});
|
|
1855
|
-
return true;
|
|
1856
|
-
}
|
|
1857
|
-
this.array[index].repeat = val;
|
|
1858
|
-
// this.normalize()
|
|
1859
|
-
return false;
|
|
1860
|
-
}
|
|
1861
|
-
//#endregion
|
|
1862
2101
|
/**
|
|
1863
2102
|
* @returns a PowiainaNum object which deep copied from `this` object.
|
|
1864
2103
|
*/
|
|
@@ -1877,6 +2116,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1877
2116
|
}, {
|
|
1878
2117
|
key: "resetFromObject",
|
|
1879
2118
|
value: function resetFromObject(powlikeObject) {
|
|
2119
|
+
if (!powlikeObject.array) {
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
1880
2122
|
this.array = [];
|
|
1881
2123
|
for (var i = 0; i < powlikeObject.array.length; i++) {
|
|
1882
2124
|
this.array[i] = {
|
|
@@ -1892,107 +2134,56 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1892
2134
|
this.layer = powlikeObject.layer;
|
|
1893
2135
|
return this;
|
|
1894
2136
|
}
|
|
1895
|
-
//#region converters
|
|
1896
|
-
/**
|
|
1897
|
-
* Convert `this` to Javascript `number`
|
|
1898
|
-
*
|
|
1899
|
-
* returns `Infinity` when the number is greater than `Number.MAX_VALUE`
|
|
1900
|
-
*/
|
|
1901
|
-
}, {
|
|
1902
|
-
key: "toNumber",
|
|
1903
|
-
value: function toNumber() {
|
|
1904
|
-
if (this.sign == -1) return -this.neg().toNumber();
|
|
1905
|
-
if (this.small) return 1 / this.rec().toNumber();
|
|
1906
|
-
if (this.array.length > 2) return Infinity;
|
|
1907
|
-
if (this.array.length == 1) return this.array[0].repeat;else if (this.array.length == 2 && this.array[1].arrow == 1 && this.array[1].expans == 1 && this.array[1].megota == 1 && this.array[1].repeat == 1) return Math.pow(10, this.getOperator(0));
|
|
1908
|
-
return NaN;
|
|
1909
|
-
}
|
|
1910
|
-
/**
|
|
1911
|
-
* Convert `this` to a string
|
|
1912
|
-
*/
|
|
1913
|
-
}, {
|
|
1914
|
-
key: "toString",
|
|
1915
|
-
value: function toString() {
|
|
1916
|
-
if (this.isNaN()) return "NaN";
|
|
1917
|
-
if (this.sign == -1) return "-".concat(this.neg().toString());
|
|
1918
|
-
if (this.small) {
|
|
1919
|
-
if (this.isZero()) return "0";
|
|
1920
|
-
return "/".concat(this.rec().toString());
|
|
1921
|
-
}
|
|
1922
|
-
if (this.isInfi()) return "Infinity";
|
|
1923
|
-
// P^a (10{arrow,expans,megota})^repeation base
|
|
1924
|
-
var res = "";
|
|
1925
|
-
if (!this.layer) res += "";else if (this.layer < 3) res += "P".repeat(this.layer);else res += "P^" + this.layer + " ";
|
|
1926
|
-
for (var i = this.array.length - 1; i >= 0; i--) {
|
|
1927
|
-
var oper = this.array[i];
|
|
1928
|
-
var calc = "10{".concat(oper.arrow === Infinity ? "!" : oper.arrow).concat(oper.expans > 1 || oper.megota > 1 ? ",".concat(oper.expans === Infinity ? "!" : oper.expans) : "").concat(oper.megota > 1 ? ",".concat(oper.megota) : "", "}");
|
|
1929
|
-
if (oper.arrow == 1 && oper.expans == 1 && oper.megota == 1 && oper.repeat < 5) {
|
|
1930
|
-
calc = "e".repeat(oper.repeat);
|
|
1931
|
-
} else if (oper.arrow == 0 && oper.expans == 1 && oper.megota == 1) {
|
|
1932
|
-
calc = oper.repeat.toString();
|
|
1933
|
-
} else if (oper.repeat > 1) {
|
|
1934
|
-
calc = "(".concat(calc, ")^").concat(oper.repeat, " ");
|
|
1935
|
-
} else {
|
|
1936
|
-
calc = "".concat(calc);
|
|
1937
|
-
}
|
|
1938
|
-
res += "".concat(calc);
|
|
1939
|
-
}
|
|
1940
|
-
return res;
|
|
1941
|
-
}
|
|
1942
|
-
}, {
|
|
1943
|
-
key: "toJSON",
|
|
1944
|
-
value:
|
|
1945
|
-
/**
|
|
1946
|
-
* Convert `this` to a JSON object
|
|
1947
|
-
* @returns a JSON object
|
|
1948
|
-
*/
|
|
1949
|
-
function toJSON() {
|
|
1950
|
-
return "PN" + this.toString();
|
|
1951
|
-
}
|
|
1952
|
-
}, {
|
|
1953
|
-
key: "arr01",
|
|
1954
|
-
get:
|
|
1955
|
-
/**
|
|
1956
|
-
* A property array value for version 0.1.x PowiainaNum.
|
|
1957
|
-
*/
|
|
1958
|
-
function get() {
|
|
1959
|
-
var res = [0];
|
|
1960
|
-
for (var i = 0; i < this.array.length; i++) {
|
|
1961
|
-
if (i == 0) res[0] = this.array[i].repeat;else {
|
|
1962
|
-
// @ts-ignore
|
|
1963
|
-
res[i] = [0, 0, 0, 0];
|
|
1964
|
-
// @ts-ignore
|
|
1965
|
-
res[i][0] = this.array[i].arrow == Infinity ? "x" : this.array[i].arrow;
|
|
1966
|
-
// @ts-ignore
|
|
1967
|
-
res[i][1] = this.array[i].repeat;
|
|
1968
|
-
// @ts-ignore
|
|
1969
|
-
res[i][2] = this.array[i].expans == Infinity ? "x" : this.array[i].expans;
|
|
1970
|
-
// @ts-ignore
|
|
1971
|
-
res[i][3] = this.array[i].megota;
|
|
1972
|
-
}
|
|
1973
|
-
}
|
|
1974
|
-
return res;
|
|
1975
|
-
}
|
|
1976
2137
|
}], [{
|
|
1977
2138
|
key: "add",
|
|
1978
2139
|
value: function add(t, other) {
|
|
1979
2140
|
return new PowiainaNum(t).add(other);
|
|
1980
2141
|
}
|
|
2142
|
+
}, {
|
|
2143
|
+
key: "plus",
|
|
2144
|
+
value: function plus(t, other) {
|
|
2145
|
+
return new PowiainaNum(t).add(other);
|
|
2146
|
+
}
|
|
1981
2147
|
}, {
|
|
1982
2148
|
key: "sub",
|
|
1983
2149
|
value: function sub(t, other) {
|
|
1984
2150
|
return new PowiainaNum(t).sub(other);
|
|
1985
2151
|
}
|
|
2152
|
+
}, {
|
|
2153
|
+
key: "minus",
|
|
2154
|
+
value: function minus(t, other) {
|
|
2155
|
+
return new PowiainaNum(t).sub(other);
|
|
2156
|
+
}
|
|
1986
2157
|
}, {
|
|
1987
2158
|
key: "mul",
|
|
1988
2159
|
value: function mul(t, other) {
|
|
1989
2160
|
return new PowiainaNum(t).mul(other);
|
|
1990
2161
|
}
|
|
2162
|
+
}, {
|
|
2163
|
+
key: "times",
|
|
2164
|
+
value: function times(t, other) {
|
|
2165
|
+
return new PowiainaNum(t).mul(other);
|
|
2166
|
+
}
|
|
1991
2167
|
}, {
|
|
1992
2168
|
key: "div",
|
|
1993
2169
|
value: function div(t, other) {
|
|
1994
2170
|
return new PowiainaNum(t).div(other);
|
|
1995
2171
|
}
|
|
2172
|
+
}, {
|
|
2173
|
+
key: "divide",
|
|
2174
|
+
value: function divide(t, other) {
|
|
2175
|
+
return new PowiainaNum(t).div(other);
|
|
2176
|
+
}
|
|
2177
|
+
}, {
|
|
2178
|
+
key: "mod",
|
|
2179
|
+
value: function mod(x, y) {
|
|
2180
|
+
return new PowiainaNum(x).mod(y);
|
|
2181
|
+
}
|
|
2182
|
+
}, {
|
|
2183
|
+
key: "modulus",
|
|
2184
|
+
value: function modulus(x, y) {
|
|
2185
|
+
return new PowiainaNum(x).mod(y);
|
|
2186
|
+
}
|
|
1996
2187
|
}, {
|
|
1997
2188
|
key: "pow",
|
|
1998
2189
|
value: function pow(t, other) {
|
|
@@ -2024,6 +2215,17 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2024
2215
|
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.E;
|
|
2025
2216
|
return new PowiainaNum(t).log(base);
|
|
2026
2217
|
}
|
|
2218
|
+
}, {
|
|
2219
|
+
key: "log2",
|
|
2220
|
+
value: function log2(t) {
|
|
2221
|
+
return new PowiainaNum(t).log2();
|
|
2222
|
+
}
|
|
2223
|
+
}, {
|
|
2224
|
+
key: "logBase",
|
|
2225
|
+
value: function logBase(t) {
|
|
2226
|
+
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.E;
|
|
2227
|
+
return new PowiainaNum(t).log(base);
|
|
2228
|
+
}
|
|
2027
2229
|
}, {
|
|
2028
2230
|
key: "pLog10",
|
|
2029
2231
|
value: function pLog10(t) {
|
|
@@ -2175,6 +2377,27 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2175
2377
|
};
|
|
2176
2378
|
}
|
|
2177
2379
|
}
|
|
2380
|
+
}, {
|
|
2381
|
+
key: "pentate",
|
|
2382
|
+
value: function pentate(x, other, payload) {
|
|
2383
|
+
return new PowiainaNum(x).arrow(3)(other, payload);
|
|
2384
|
+
}
|
|
2385
|
+
}, {
|
|
2386
|
+
key: "hexate",
|
|
2387
|
+
value: function hexate(x, other, payload) {
|
|
2388
|
+
return new PowiainaNum(x).arrow(4)(other, payload);
|
|
2389
|
+
}
|
|
2390
|
+
}, {
|
|
2391
|
+
key: "pent",
|
|
2392
|
+
value: function pent(x, other, payload) {
|
|
2393
|
+
return new PowiainaNum(x).arrow(3)(other, payload);
|
|
2394
|
+
}
|
|
2395
|
+
}, {
|
|
2396
|
+
key: "penta_log",
|
|
2397
|
+
value: function penta_log(x) {
|
|
2398
|
+
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
2399
|
+
return new PowiainaNum(x).anyarrow_log(3)(base);
|
|
2400
|
+
}
|
|
2178
2401
|
}, {
|
|
2179
2402
|
key: "expansion",
|
|
2180
2403
|
value: function expansion(t, other) {
|
|
@@ -2273,9 +2496,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2273
2496
|
if (a == 0 && e == 1 && m > 1) {
|
|
2274
2497
|
return [1, 1 / 0, m - 1];
|
|
2275
2498
|
}
|
|
2276
|
-
if (e == 0 && m > 1) {
|
|
2277
|
-
return [1, 1 / 0, m - 1];
|
|
2278
|
-
}
|
|
2279
2499
|
return [a, e, m];
|
|
2280
2500
|
}
|
|
2281
2501
|
if (megota.gt(MSI)) {
|
|
@@ -2289,8 +2509,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2289
2509
|
return x.toString();
|
|
2290
2510
|
}
|
|
2291
2511
|
function getMSIForm(arrow, expans, megota) {
|
|
2292
|
-
|
|
2293
|
-
return "10{".concat(infToBang(conv[0]), ",").concat(infToBang(conv[1]), ",").concat(conv[2], "}").concat(MSI);
|
|
2512
|
+
return "10{".concat(infToBang(arrow), ",").concat(infToBang(expans), ",").concat(megota, "}").concat(MSI);
|
|
2294
2513
|
}
|
|
2295
2514
|
var t = base.clone();
|
|
2296
2515
|
var arrows = new PowiainaNum(readArg(0));
|
|
@@ -2298,14 +2517,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2298
2517
|
var _r, _r2;
|
|
2299
2518
|
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
2300
2519
|
console.log("".concat("-".repeat(depth), " {").concat(base2, ",").concat(power2, ",").concat(arrow2, ",").concat(expans2, ",").concat(megota2, "}"));
|
|
2301
|
-
if (depth >= 200) {
|
|
2302
|
-
return new PowiainaNum({
|
|
2303
|
-
layer: 0,
|
|
2304
|
-
array: [newOperator(10), newOperator(1, new PowiainaNum(arrow2).clampMax(MSI).toNumber(), new PowiainaNum(expans2).clampMax(MSI).toNumber(), new PowiainaNum(megota2).clampMax(MSI).toNumber())],
|
|
2305
|
-
sign: 1,
|
|
2306
|
-
small: false
|
|
2307
|
-
}).normalize();
|
|
2308
|
-
}
|
|
2309
2520
|
var other = new PowiainaNum(other2);
|
|
2310
2521
|
var r;
|
|
2311
2522
|
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
|
|
@@ -2323,7 +2534,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2323
2534
|
}
|
|
2324
2535
|
if (expans.eq(0)) {
|
|
2325
2536
|
return PowiainaNum.BEAF(t, t, t, power, megota.sub(1), powiaina2, depth + 1);
|
|
2326
|
-
// {this, this, power,
|
|
2537
|
+
// {this, this, this, power, megota-1}
|
|
2327
2538
|
}
|
|
2328
2539
|
if (megota.eq(0)) {
|
|
2329
2540
|
return PowiainaNum.BEAF(t, t, t, t, expans, new PowiainaNum(powiaina2).sub(1), depth + 1);
|
|
@@ -2442,6 +2653,84 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2442
2653
|
value: function clampMax() {
|
|
2443
2654
|
return PowiainaNum.min.apply(PowiainaNum, arguments);
|
|
2444
2655
|
}
|
|
2656
|
+
}, {
|
|
2657
|
+
key: "eq",
|
|
2658
|
+
value: function eq(a, o) {
|
|
2659
|
+
return new PowiainaNum(a).eq(o);
|
|
2660
|
+
}
|
|
2661
|
+
}, {
|
|
2662
|
+
key: "equals",
|
|
2663
|
+
value: function equals(a, o) {
|
|
2664
|
+
return new PowiainaNum(a).eq(o);
|
|
2665
|
+
}
|
|
2666
|
+
}, {
|
|
2667
|
+
key: "neq",
|
|
2668
|
+
value: function neq(a, o) {
|
|
2669
|
+
return new PowiainaNum(a).neq(o);
|
|
2670
|
+
}
|
|
2671
|
+
}, {
|
|
2672
|
+
key: "notEquals",
|
|
2673
|
+
value: function notEquals(a, o) {
|
|
2674
|
+
return new PowiainaNum(a).notEquals(o);
|
|
2675
|
+
}
|
|
2676
|
+
}, {
|
|
2677
|
+
key: "lt",
|
|
2678
|
+
value: function lt(a, o) {
|
|
2679
|
+
return new PowiainaNum(a).lt(o);
|
|
2680
|
+
}
|
|
2681
|
+
}, {
|
|
2682
|
+
key: "gt",
|
|
2683
|
+
value: function gt(a, o) {
|
|
2684
|
+
return new PowiainaNum(a).gt(o);
|
|
2685
|
+
}
|
|
2686
|
+
}, {
|
|
2687
|
+
key: "lte",
|
|
2688
|
+
value: function lte(a, o) {
|
|
2689
|
+
return new PowiainaNum(a).lte(o);
|
|
2690
|
+
}
|
|
2691
|
+
}, {
|
|
2692
|
+
key: "gte",
|
|
2693
|
+
value: function gte(a, o) {
|
|
2694
|
+
return new PowiainaNum(a).gte(o);
|
|
2695
|
+
}
|
|
2696
|
+
}, {
|
|
2697
|
+
key: "rec",
|
|
2698
|
+
value: function rec(t) {
|
|
2699
|
+
return new PowiainaNum(t).rec();
|
|
2700
|
+
}
|
|
2701
|
+
}, {
|
|
2702
|
+
key: "recip",
|
|
2703
|
+
value: function recip(t) {
|
|
2704
|
+
return new PowiainaNum(t).rec();
|
|
2705
|
+
}
|
|
2706
|
+
}, {
|
|
2707
|
+
key: "reciprocate",
|
|
2708
|
+
value: function reciprocate(t) {
|
|
2709
|
+
return new PowiainaNum(t).rec();
|
|
2710
|
+
}
|
|
2711
|
+
}, {
|
|
2712
|
+
key: "floor",
|
|
2713
|
+
value: function floor(x) {
|
|
2714
|
+
return new PowiainaNum(x).floor();
|
|
2715
|
+
}
|
|
2716
|
+
}, {
|
|
2717
|
+
key: "ceil",
|
|
2718
|
+
value: function ceil(x) {
|
|
2719
|
+
return new PowiainaNum(x).ceil();
|
|
2720
|
+
}
|
|
2721
|
+
}, {
|
|
2722
|
+
key: "round",
|
|
2723
|
+
value: function round(x) {
|
|
2724
|
+
return new PowiainaNum(x).round();
|
|
2725
|
+
}
|
|
2726
|
+
}, {
|
|
2727
|
+
key: "trunc",
|
|
2728
|
+
value: function trunc(x) {
|
|
2729
|
+
return new PowiainaNum(x).trunc();
|
|
2730
|
+
}
|
|
2731
|
+
/**
|
|
2732
|
+
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
2733
|
+
*/
|
|
2445
2734
|
}, {
|
|
2446
2735
|
key: "sign",
|
|
2447
2736
|
value: function sign(a) {
|
|
@@ -2456,6 +2745,17 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2456
2745
|
key: "fromNumber",
|
|
2457
2746
|
value: function fromNumber(x) {
|
|
2458
2747
|
var obj = new PowiainaNum(); // NaN
|
|
2748
|
+
obj.resetFromObject({
|
|
2749
|
+
array: [{
|
|
2750
|
+
arrow: 0,
|
|
2751
|
+
expans: 1,
|
|
2752
|
+
megota: 1,
|
|
2753
|
+
repeat: NaN
|
|
2754
|
+
}],
|
|
2755
|
+
small: false,
|
|
2756
|
+
layer: 0,
|
|
2757
|
+
sign: 0
|
|
2758
|
+
});
|
|
2459
2759
|
if (x < 0) obj.sign = -1; // negative
|
|
2460
2760
|
else if (x == 0) {
|
|
2461
2761
|
obj.sign = 0;
|
|
@@ -2483,10 +2783,26 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2483
2783
|
}, {
|
|
2484
2784
|
key: "fromString",
|
|
2485
2785
|
value: function fromString(input) {
|
|
2786
|
+
if (PowiainaNum.usingBreakEternityLikeFromString && BE_REGEX.test(input)) {
|
|
2787
|
+
/*
|
|
2788
|
+
* 0i00000000a7 says that eee-3000 will wrongly parse to 1. So i added this
|
|
2789
|
+
*/
|
|
2790
|
+
var a = input.match(/(e+-)(\d+(.\d+)?)/);
|
|
2791
|
+
if (a) {
|
|
2792
|
+
var e_s = a[1].length;
|
|
2793
|
+
input = "e-" + "e".repeat(e_s - 1) + a[2];
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
return this.fromString_core(input);
|
|
2797
|
+
}
|
|
2798
|
+
}, {
|
|
2799
|
+
key: "fromString_core",
|
|
2800
|
+
value: function fromString_core(input) {
|
|
2486
2801
|
var _b, _c, _d, _e, _f, _g;
|
|
2487
|
-
var x = new PowiainaNum();
|
|
2802
|
+
var x = new PowiainaNum(NaN);
|
|
2488
2803
|
// Judge the string was a number
|
|
2489
2804
|
if (input.startsWith("PN")) input = input.substring(2);
|
|
2805
|
+
if (input == "NaN") return PowiainaNum.NaN.clone();
|
|
2490
2806
|
input = input.replace(/J\^(\d+)/g, "(10{!})^$1");
|
|
2491
2807
|
input = input.replace(/J/g, "10{!}");
|
|
2492
2808
|
input = input.replace(/K\^(\d+)/g, "(10{1,2})^$1");
|
|
@@ -2497,17 +2813,20 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2497
2813
|
input = input.replace(/M/g, "10{!,2}");
|
|
2498
2814
|
input = input.replace(/N\^(\d+)/g, "(10{1,!})^$1");
|
|
2499
2815
|
input = input.replace(/N/g, "10{1,!}");
|
|
2816
|
+
if (/^.*e-.*(e|\^).*/.test(input)) {
|
|
2817
|
+
input = "/10^" + input.substring(input.indexOf("e-"));
|
|
2818
|
+
}
|
|
2500
2819
|
if (!isNaN(Number(input))) {
|
|
2501
2820
|
var res = Number(input);
|
|
2502
|
-
var
|
|
2821
|
+
var a = false;
|
|
2503
2822
|
if (res == 0) {
|
|
2504
2823
|
if (/^((0)|(0*\.0+e\d+)|(0*\.0*))$/.test(input)) {
|
|
2505
|
-
|
|
2824
|
+
a = true;
|
|
2506
2825
|
}
|
|
2507
2826
|
} else {
|
|
2508
|
-
|
|
2827
|
+
a = true;
|
|
2509
2828
|
}
|
|
2510
|
-
if (!
|
|
2829
|
+
if (!a) {
|
|
2511
2830
|
var m = input.search(/e/);
|
|
2512
2831
|
var exponent = input.substring((m == -1 ? input.length : m) + 1);
|
|
2513
2832
|
var mantissa = input.substring(0, m == -1 ? undefined : m);
|
|
@@ -2517,11 +2836,11 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2517
2836
|
// Is regular number gte 1:
|
|
2518
2837
|
if (Number(mantissa) >= 1) {
|
|
2519
2838
|
// check The mantissa is very long?
|
|
2520
|
-
var log10mant = mantissa.length >= LONG_STRING_MIN_LENGTH ? log10LongString(mantissa) : Math.log10(Number(mantissa));
|
|
2521
|
-
var log10int = Math.floor(log10mant);
|
|
2522
|
-
var log10float = log10mant - log10int;
|
|
2839
|
+
var log10mant = mantissa.length >= LONG_STRING_MIN_LENGTH ? log10LongString(mantissa) : Math.log10(Number(mantissa)); // sample 10
|
|
2840
|
+
var log10int = Math.floor(log10mant); // sample 1
|
|
2841
|
+
var log10float = log10mant - log10int; // sample 0;
|
|
2523
2842
|
mantissaME[0] = Math.pow(10, log10float);
|
|
2524
|
-
mantissaME[1] +=
|
|
2843
|
+
mantissaME[1] += log10int;
|
|
2525
2844
|
} else {
|
|
2526
2845
|
// If not , count how many zeros until reached non-zero numbers
|
|
2527
2846
|
var zeros = countLeadingZerosAfterDecimal(mantissa);
|
|
@@ -2536,7 +2855,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2536
2855
|
// /((a*10^b)^-1) = /(a^-1*10^-b) = /(a^-1 * 10 * 10^(-b-1))
|
|
2537
2856
|
return PowiainaNum.pow(10, -mantissaME[1] - 1).mul(Math.pow(mantissaME[0], -1) * 10).rec();
|
|
2538
2857
|
}
|
|
2539
|
-
if (isFinite(res) &&
|
|
2858
|
+
if (isFinite(res) && a) {
|
|
2540
2859
|
x = PowiainaNum.fromNumber(Number(input));
|
|
2541
2860
|
return x;
|
|
2542
2861
|
}
|
|
@@ -2553,6 +2872,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2553
2872
|
return x;
|
|
2554
2873
|
}
|
|
2555
2874
|
input = replaceETo10(input);
|
|
2875
|
+
input = removeCommasOutsideBraces(input);
|
|
2556
2876
|
if (!isPowiainaNum.test(input)) {
|
|
2557
2877
|
throw powiainaNumError + "malformed input: " + input;
|
|
2558
2878
|
}
|
|
@@ -2565,28 +2885,31 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2565
2885
|
input = input.substring(numSigns);
|
|
2566
2886
|
}
|
|
2567
2887
|
if (input[0] == "/") {
|
|
2568
|
-
var
|
|
2569
|
-
var
|
|
2570
|
-
recipIt = ((_e = (_d =
|
|
2571
|
-
input = input.substring(
|
|
2888
|
+
var _numSigns = input.search(/[^\/]/);
|
|
2889
|
+
var _signs = input.substring(0, _numSigns);
|
|
2890
|
+
recipIt = ((_e = (_d = _signs.match(/\//g)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) % 2 == 1;
|
|
2891
|
+
input = input.substring(_numSigns);
|
|
2572
2892
|
}
|
|
2573
2893
|
if (input == "NaN") x.array = [newOperator(NaN)];else if (input == "Infinity") x.array = [newOperator(Infinity)];else {
|
|
2574
2894
|
x.sign = 1;
|
|
2575
2895
|
x.array = [newOperator(0)];
|
|
2576
|
-
var
|
|
2896
|
+
var _a3, b, c, d;
|
|
2577
2897
|
if (input[0] == "P") {
|
|
2578
2898
|
if (input[1] == "^") {
|
|
2579
|
-
|
|
2580
|
-
x.layer = Number(input.substring(2,
|
|
2581
|
-
input = input.substring(
|
|
2899
|
+
_a3 = input.substring(2).search(/[^0-9]/) + 2;
|
|
2900
|
+
x.layer = Number(input.substring(2, _a3));
|
|
2901
|
+
input = input.substring(_a3 + 1);
|
|
2582
2902
|
} else {
|
|
2583
|
-
|
|
2584
|
-
x.layer =
|
|
2585
|
-
input = input.substring(
|
|
2903
|
+
_a3 = input.search(/[^P]/);
|
|
2904
|
+
x.layer = _a3;
|
|
2905
|
+
input = input.substring(_a3);
|
|
2586
2906
|
}
|
|
2587
2907
|
}
|
|
2588
2908
|
while (input) {
|
|
2589
2909
|
if (/^(\(?10[\^\{])/.test(input)) {
|
|
2910
|
+
var arrows = void 0,
|
|
2911
|
+
expans = void 0,
|
|
2912
|
+
megota = void 0;
|
|
2590
2913
|
/*
|
|
2591
2914
|
10^ - 匹配
|
|
2592
2915
|
10{ - 匹配
|
|
@@ -2597,30 +2920,29 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2597
2920
|
*/
|
|
2598
2921
|
if (input[0] == "(") input = input.substring(1);
|
|
2599
2922
|
//cutted, 10^.... or 10{....
|
|
2600
|
-
var arrows, expans, megota;
|
|
2601
2923
|
if (input[2] == "^") {
|
|
2602
|
-
|
|
2924
|
+
_a3 = input.substring(2).search(/[^\^]/);
|
|
2603
2925
|
//cut input to ^^...^^, and search how numbers
|
|
2604
|
-
arrows =
|
|
2926
|
+
arrows = _a3;
|
|
2605
2927
|
// 10^^^
|
|
2606
|
-
b =
|
|
2928
|
+
b = _a3 + 2; // b points to after ^'s.
|
|
2607
2929
|
} else {
|
|
2608
2930
|
// 10{...}
|
|
2609
|
-
|
|
2931
|
+
_a3 = input.indexOf("}");
|
|
2610
2932
|
// select contents between {...}
|
|
2611
|
-
var tmp = input.substring(3,
|
|
2933
|
+
var tmp = input.substring(3, _a3).split(",");
|
|
2612
2934
|
arrows = Number(tmp[0] == "!" ? Infinity : tmp[0]);
|
|
2613
2935
|
expans = Number((_f = tmp[1] == "!" ? Infinity : tmp[1]) !== null && _f !== void 0 ? _f : 1);
|
|
2614
2936
|
megota = Number((_g = tmp[2]) !== null && _g !== void 0 ? _g : 1);
|
|
2615
|
-
b =
|
|
2937
|
+
b = _a3 + 1;
|
|
2616
2938
|
// b points to after }.
|
|
2617
2939
|
}
|
|
2618
2940
|
input = input.substring(b);
|
|
2619
2941
|
if (input[0] == ")") {
|
|
2620
2942
|
// )^....<Space>
|
|
2621
|
-
|
|
2622
|
-
c = Number(input.substring(2,
|
|
2623
|
-
input = input.substring(
|
|
2943
|
+
_a3 = input.indexOf(" ");
|
|
2944
|
+
c = Number(input.substring(2, _a3)); // Select contents between )^....<Space>
|
|
2945
|
+
input = input.substring(_a3 + 1); // c points to after <Space>
|
|
2624
2946
|
} else {
|
|
2625
2947
|
c = 1; // There is only spaces, count as <ONE>
|
|
2626
2948
|
}
|
|
@@ -2631,21 +2953,21 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2631
2953
|
x.array.splice(1, 0, newOperator(c, 1, expans, megota));
|
|
2632
2954
|
}
|
|
2633
2955
|
} else if (arrows == 2 && expans == 1 && megota == 1) {
|
|
2634
|
-
|
|
2956
|
+
_a3 = x.array.length >= 2 && x.array[1].arrow == 1 ? x.array[1].repeat : 0;
|
|
2635
2957
|
b = x.array[0].repeat;
|
|
2636
|
-
if (b >= 1e10) ++
|
|
2637
|
-
if (b >= 10) ++
|
|
2638
|
-
x.array[0].repeat =
|
|
2958
|
+
if (b >= 1e10) ++_a3;
|
|
2959
|
+
if (b >= 10) ++_a3;
|
|
2960
|
+
x.array[0].repeat = _a3;
|
|
2639
2961
|
if (x.array.length >= 2 && x.array[1].arrow == 1) x.array.splice(1, 1);
|
|
2640
2962
|
d = x.getOperatorIndex(2);
|
|
2641
2963
|
if (Number.isInteger(d)) x.array[d].repeat += c;else x.array.splice(Math.ceil(d), 0, newOperator(c, 2, expans, megota));
|
|
2642
2964
|
} else if (isFinite(arrows)) {
|
|
2643
|
-
|
|
2965
|
+
_a3 = x.getOperator(arrows - 1);
|
|
2644
2966
|
b = x.getOperator(arrows - 2);
|
|
2645
|
-
if (b >= 10) ++
|
|
2967
|
+
if (b >= 10) ++_a3;
|
|
2646
2968
|
d = x.getOperatorIndex(arrows);
|
|
2647
2969
|
x.array.splice(1, Math.ceil(d) - 1);
|
|
2648
|
-
x.array[0].repeat =
|
|
2970
|
+
x.array[0].repeat = _a3;
|
|
2649
2971
|
if (Number.isInteger(d)) x.array[1].repeat += c;else x.array.splice(1, 0, newOperator(c, arrows, expans, megota));
|
|
2650
2972
|
} else {
|
|
2651
2973
|
x.array.splice(1, 0, newOperator(c, arrows, expans, megota));
|
|
@@ -2654,10 +2976,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2654
2976
|
break;
|
|
2655
2977
|
}
|
|
2656
2978
|
}
|
|
2657
|
-
|
|
2979
|
+
_a3 = input.split(/[Ee]/);
|
|
2658
2980
|
b = [x.array[0].repeat, 0];
|
|
2659
2981
|
c = 1;
|
|
2660
|
-
for (var
|
|
2982
|
+
for (var i = _a3.length - 1; i >= 0; --i) {
|
|
2661
2983
|
//The things that are already there
|
|
2662
2984
|
if (b[0] < MSI_LOG10 && b[1] === 0) {
|
|
2663
2985
|
b[0] = Math.pow(10, c * b[0]);
|
|
@@ -2674,12 +2996,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2674
2996
|
b[1]++;
|
|
2675
2997
|
}
|
|
2676
2998
|
//Multiplying coefficient
|
|
2677
|
-
var decimalPointPos =
|
|
2678
|
-
var intPartLen = decimalPointPos == -1 ?
|
|
2999
|
+
var decimalPointPos = _a3[i].indexOf(".");
|
|
3000
|
+
var intPartLen = decimalPointPos == -1 ? _a3[i].length : decimalPointPos;
|
|
2679
3001
|
if (b[1] === 0) {
|
|
2680
|
-
if (intPartLen >= LONG_STRING_MIN_LENGTH) b[0] = Math.log10(b[0]) + log10LongString(
|
|
3002
|
+
if (intPartLen >= LONG_STRING_MIN_LENGTH) b[0] = Math.log10(b[0]) + log10LongString(_a3[i].substring(0, intPartLen)), b[1] = 1;else if (_a3[i]) b[0] *= Number(_a3[i]);
|
|
2681
3003
|
} else {
|
|
2682
|
-
d = intPartLen >= LONG_STRING_MIN_LENGTH ? log10LongString(
|
|
3004
|
+
d = intPartLen >= LONG_STRING_MIN_LENGTH ? log10LongString(_a3[i].substring(0, intPartLen)) : _a3[i] ? Math.log10(Number(_a3[i])) : 0;
|
|
2683
3005
|
if (b[1] == 1) {
|
|
2684
3006
|
b[0] += d;
|
|
2685
3007
|
} else if (b[1] == 2 && b[0] < MSI_LOG10 + Math.log10(d)) {
|
|
@@ -2710,6 +3032,17 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2710
3032
|
key: "fromObject",
|
|
2711
3033
|
value: function fromObject(powlikeObject) {
|
|
2712
3034
|
var obj = new PowiainaNum();
|
|
3035
|
+
obj.resetFromObject({
|
|
3036
|
+
array: [{
|
|
3037
|
+
arrow: 0,
|
|
3038
|
+
expans: 1,
|
|
3039
|
+
megota: 1,
|
|
3040
|
+
repeat: NaN
|
|
3041
|
+
}],
|
|
3042
|
+
small: false,
|
|
3043
|
+
layer: 0,
|
|
3044
|
+
sign: 0
|
|
3045
|
+
});
|
|
2713
3046
|
obj.array = [];
|
|
2714
3047
|
if (isExpantaNumArray(powlikeObject)) {
|
|
2715
3048
|
for (var i = 0; i < powlikeObject.length; i++) {
|
|
@@ -2727,8 +3060,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2727
3060
|
} else if (isPowiainaNum01XArray(powlikeObject)) {
|
|
2728
3061
|
var arrayobj = powlikeObject;
|
|
2729
3062
|
obj.array[0] = newOperator(arrayobj[0]);
|
|
2730
|
-
for (var
|
|
2731
|
-
var b = arrayobj[
|
|
3063
|
+
for (var _i4 = 1; _i4 < arrayobj.length; _i4++) {
|
|
3064
|
+
var b = arrayobj[_i4];
|
|
2732
3065
|
obj.array[1] = newOperator(b[1], replaceXToInfinity(b[0]), replaceXToInfinity(b[2]), b[3]);
|
|
2733
3066
|
}
|
|
2734
3067
|
obj.small = false;
|
|
@@ -2736,21 +3069,21 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2736
3069
|
obj.layer = 0;
|
|
2737
3070
|
return obj;
|
|
2738
3071
|
} else {
|
|
2739
|
-
|
|
2740
|
-
obj.array[_i4] = {
|
|
2741
|
-
arrow: powlikeObject.array[_i4].arrow,
|
|
2742
|
-
expans: powlikeObject.array[_i4].expans,
|
|
2743
|
-
megota: powlikeObject.array[_i4].megota,
|
|
2744
|
-
repeat: powlikeObject.array[_i4].repeat,
|
|
2745
|
-
valuereplaced: powlikeObject.array[_i4].valuereplaced
|
|
2746
|
-
};
|
|
2747
|
-
}
|
|
2748
|
-
obj.small = powlikeObject.small;
|
|
2749
|
-
obj.sign = powlikeObject.sign;
|
|
2750
|
-
obj.layer = powlikeObject.layer;
|
|
3072
|
+
obj.resetFromObject(powlikeObject);
|
|
2751
3073
|
return obj;
|
|
2752
3074
|
}
|
|
2753
3075
|
}
|
|
3076
|
+
}, {
|
|
3077
|
+
key: "grahalFunction",
|
|
3078
|
+
value: function grahalFunction(layers2) {
|
|
3079
|
+
var layers = new PowiainaNum(layers2);
|
|
3080
|
+
if (!layers.isInt() || layers.lt(0) || layers.isNaN()) return PowiainaNum.NaN.clone();
|
|
3081
|
+
if (layers.eq(1)) return new PowiainaNum("10^^^(10^)^7625597484984 3638334640023.7783");else if (layers.lte(MSI)) {
|
|
3082
|
+
return new PowiainaNum("(10{!})^".concat(layers.toNumber(), " 10^^^(10^)^7625597484984 3638334640023.7783"));
|
|
3083
|
+
} else {
|
|
3084
|
+
return PowiainaNum.BEAF(3, layers, 1, 2);
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
2754
3087
|
}]);
|
|
2755
3088
|
}();
|
|
2756
3089
|
_a = Symbol.toStringTag;
|
|
@@ -2967,6 +3300,15 @@ PowiainaNum.maxOps = 100;
|
|
|
2967
3300
|
PowiainaNum.POW_2_44_MOD_PI = 1.701173079953;
|
|
2968
3301
|
//#endregion
|
|
2969
3302
|
PowiainaNum.arrowFuncMap = new Map();
|
|
3303
|
+
//#region configurations
|
|
3304
|
+
/**
|
|
3305
|
+
* If you set this config to true, the `fromString` method will try to parse the string to `PowiainaNum` class with `break_eternity.js` similar `fromString` method, if cannot parse correctly, the program will use `PowiainaNum.js` `fromString` method.
|
|
3306
|
+
*/
|
|
3307
|
+
PowiainaNum.usingBreakEternityLikeFromString = false;
|
|
3308
|
+
/**
|
|
3309
|
+
* If you set this config to true, the `constructor` method will return Zero instead of NaN when call new PowiainaNum() with no arguments.
|
|
3310
|
+
*/
|
|
3311
|
+
PowiainaNum.blankArgumentConstructorReturnZero = false;
|
|
2970
3312
|
|
|
2971
3313
|
exports.arraySortFunction = arraySortFunction;
|
|
2972
3314
|
exports["default"] = PowiainaNum;
|