powiaina_num.js 0.2.12 → 0.2.14
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 +718 -312
- package/dist/PowiainaNum.esm.js +718 -312
- package/dist/PowiainaNum.js +718 -312
- package/dist/PowiainaNum.min.js +1 -1
- package/dist/index.d.ts +82 -18
- package/package.json +1 -1
package/dist/PowiainaNum.esm.js
CHANGED
|
@@ -62,6 +62,8 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
62
62
|
|
|
63
63
|
/* Author: VeryrrDefine 0.2.0-beta.1.1*/
|
|
64
64
|
var _a;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region constants
|
|
65
67
|
var powiainaNumError = "[PowiainaNum 0.2 error]";
|
|
66
68
|
var MSI = 9007199254740991;
|
|
67
69
|
var MSI_LOG10 = 15.954589770191003;
|
|
@@ -69,6 +71,8 @@ var MSI_REC = 1.1102230246251568e-16;
|
|
|
69
71
|
var LONG_STRING_MIN_LENGTH = 17;
|
|
70
72
|
var EXP_E_REC = 1.444667861009766;
|
|
71
73
|
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+))$/;
|
|
74
|
+
var BE_REGEX = /^((\d+(\.\d*)?|\d*\.\d+)?([EeFf]([-\+]?)))*(0|\d+(\.\d*)?|\d*\.\d+)$/;
|
|
75
|
+
//#endregion
|
|
72
76
|
//#region some useful functions
|
|
73
77
|
function newOperator(r) {
|
|
74
78
|
var a = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
@@ -82,6 +86,29 @@ function newOperator(r) {
|
|
|
82
86
|
valuereplaced: a == Infinity ? 0 : e == Infinity ? 1 : -1
|
|
83
87
|
};
|
|
84
88
|
}
|
|
89
|
+
function removeCommasOutsideBraces(input) {
|
|
90
|
+
var result = "";
|
|
91
|
+
var inBraces = false;
|
|
92
|
+
for (var i = 0; i < input.length; i++) {
|
|
93
|
+
var _char = input[i];
|
|
94
|
+
if (_char === "{") {
|
|
95
|
+
inBraces = true;
|
|
96
|
+
result += _char;
|
|
97
|
+
} else if (_char === "}") {
|
|
98
|
+
inBraces = false;
|
|
99
|
+
result += _char;
|
|
100
|
+
} else if (_char === ",") {
|
|
101
|
+
// 只有在花括号内部才保留逗号
|
|
102
|
+
if (inBraces) {
|
|
103
|
+
result += _char;
|
|
104
|
+
}
|
|
105
|
+
// 如果在花括号外部,就不添加到结果中(相当于删除)
|
|
106
|
+
} else {
|
|
107
|
+
result += _char;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
}
|
|
85
112
|
// parse 0.1.x PowiainaNum.js string
|
|
86
113
|
function parseLegacyPowiainaNumString(str) {
|
|
87
114
|
var pattern = /l(\d+)\s+s(\d+)\s+a(\[.*\])/;
|
|
@@ -114,7 +141,7 @@ function compareTuples() {
|
|
|
114
141
|
function replaceETo10(str) {
|
|
115
142
|
// 使用正则表达式匹配 (e^数字) 的模式
|
|
116
143
|
// 正则解释:\(e\^(\d+)\) 匹配 (e^数字),其中 \d+ 匹配一个或多个数字
|
|
117
|
-
return str.replace(/\(e\^(\d+)\)/g, "(10^)^$1 ").replace(/(\d+)
|
|
144
|
+
return str.replace(/\(e\^(\d+)\)/g, "(10^)^$1 ").replace(/(\d+)[Pp][Tt]/g, "(10^)^$1 ");
|
|
118
145
|
}
|
|
119
146
|
/**
|
|
120
147
|
* 把一个字符串很长的数进行以10为底的对数
|
|
@@ -168,8 +195,10 @@ var OMEGA = 0.56714329040978387299997; // W(1, 0)
|
|
|
168
195
|
// The evaluation can become inaccurate very close to the branch point
|
|
169
196
|
// Evaluates W(x, 0) if principal is true, W(x, -1) if principal is false
|
|
170
197
|
function f_lambertw(z) {
|
|
171
|
-
var
|
|
172
|
-
var
|
|
198
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e-10;
|
|
199
|
+
var pr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
200
|
+
var tol = t;
|
|
201
|
+
var principal = pr;
|
|
173
202
|
var w;
|
|
174
203
|
var wn;
|
|
175
204
|
if (!Number.isFinite(z)) {
|
|
@@ -332,16 +361,27 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
332
361
|
this.small = false;
|
|
333
362
|
this.sign = 0;
|
|
334
363
|
this.layer = 0;
|
|
335
|
-
if (
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
364
|
+
if (PowiainaNum.blankArgumentConstructorReturnZero) {
|
|
365
|
+
this.resetFromObject(PowiainaNum.ZERO);
|
|
366
|
+
}
|
|
367
|
+
try {
|
|
368
|
+
if (typeof arg1 == "undefined") {} else if (typeof arg1 == "number") {
|
|
369
|
+
var obj = PowiainaNum.fromNumber(arg1);
|
|
370
|
+
this.resetFromObject(obj);
|
|
371
|
+
} else if (_typeof(arg1) == "object") {
|
|
372
|
+
var _obj = PowiainaNum.fromObject(arg1);
|
|
373
|
+
this.resetFromObject(_obj);
|
|
374
|
+
} else if (typeof arg1 == "string") {
|
|
375
|
+
var _obj2 = PowiainaNum.fromString(arg1);
|
|
376
|
+
this.resetFromObject(_obj2);
|
|
377
|
+
} else {
|
|
378
|
+
var isn = arg1;
|
|
379
|
+
}
|
|
380
|
+
} catch (e) {
|
|
381
|
+
console.error("Malformed input");
|
|
382
|
+
console.error(e);
|
|
383
|
+
if (PowiainaNum.throwErrorOnResultNaN && PowiainaNum.isNaN(this)) throw new Error("NaN");
|
|
384
|
+
}
|
|
345
385
|
}
|
|
346
386
|
//#region 4 Basic calculates.
|
|
347
387
|
/**
|
|
@@ -352,10 +392,13 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
352
392
|
key: "add",
|
|
353
393
|
value: function add(other) {
|
|
354
394
|
var _b, _c, _d, _e;
|
|
355
|
-
var x = this.clone();
|
|
395
|
+
var x = this.clone().normalize();
|
|
356
396
|
var y = new PowiainaNum(other);
|
|
357
397
|
// inf + -inf = nan
|
|
358
|
-
if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY))
|
|
398
|
+
if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY)) {
|
|
399
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
400
|
+
return PowiainaNum.NaN.clone();
|
|
401
|
+
}
|
|
359
402
|
// inf & nan check
|
|
360
403
|
if (!x.isFinite()) return x.clone();
|
|
361
404
|
if (!y.isFinite()) return y.clone();
|
|
@@ -395,40 +438,56 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
395
438
|
if (isFinite(temp) && temp !== 0) {
|
|
396
439
|
return PowiainaNum.fromNumber(temp);
|
|
397
440
|
}
|
|
398
|
-
var
|
|
441
|
+
var signMult = 1;
|
|
442
|
+
/**Calculate numbers [1, 9e15] (useless) */
|
|
399
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) {
|
|
400
444
|
return new PowiainaNum((a.array[0].repeat + b.array[0].repeat) * a.sign);
|
|
401
445
|
}
|
|
446
|
+
// Calculate a & b's 10-logarithm
|
|
402
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));
|
|
403
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));
|
|
404
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
|
+
*/
|
|
405
453
|
var offset = -Math.floor(alog10); //a number can make a+off in [0,1)
|
|
406
|
-
var
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
if (
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
if (
|
|
419
|
-
|
|
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) */
|
|
420
469
|
} else {
|
|
421
|
-
|
|
470
|
+
resultPN.array = [newOperator(Math.pow(10, Math.abs(resultLogarithm)), 0)];
|
|
422
471
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
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);
|
|
426
480
|
}
|
|
427
481
|
}, {
|
|
428
482
|
key: "sub",
|
|
429
483
|
value: function sub(a) {
|
|
430
484
|
return this.add(new PowiainaNum(a).neg());
|
|
431
485
|
}
|
|
486
|
+
}, {
|
|
487
|
+
key: "minus",
|
|
488
|
+
value: function minus(other) {
|
|
489
|
+
return this.sub(other);
|
|
490
|
+
}
|
|
432
491
|
}, {
|
|
433
492
|
key: "mul",
|
|
434
493
|
value: function mul(other) {
|
|
@@ -436,7 +495,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
436
495
|
var y = new PowiainaNum(other);
|
|
437
496
|
// inf * -inf = -inf
|
|
438
497
|
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.clone();
|
|
439
|
-
if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero())
|
|
498
|
+
if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero()) {
|
|
499
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
500
|
+
return PowiainaNum.NaN.clone();
|
|
501
|
+
}
|
|
440
502
|
if (x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.POSITIVE_INFINITY.clone();
|
|
441
503
|
// inf & nan check
|
|
442
504
|
if (!x.isFinite()) return x.clone();
|
|
@@ -462,12 +524,22 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
462
524
|
r.sign = x.sign * y.sign;
|
|
463
525
|
return r;
|
|
464
526
|
}
|
|
527
|
+
}, {
|
|
528
|
+
key: "times",
|
|
529
|
+
value: function times(other) {
|
|
530
|
+
return this.mul(other);
|
|
531
|
+
}
|
|
465
532
|
}, {
|
|
466
533
|
key: "div",
|
|
467
534
|
value: function div(other) {
|
|
468
535
|
var x = new PowiainaNum(other).rec();
|
|
469
536
|
return this.mul(x);
|
|
470
537
|
}
|
|
538
|
+
}, {
|
|
539
|
+
key: "divide",
|
|
540
|
+
value: function divide(other) {
|
|
541
|
+
return this.div(other);
|
|
542
|
+
}
|
|
471
543
|
}, {
|
|
472
544
|
key: "mod",
|
|
473
545
|
value: function mod(x) {
|
|
@@ -475,34 +547,45 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
475
547
|
var division = this.div(other);
|
|
476
548
|
return division.sub(division.floor()).mul(other);
|
|
477
549
|
}
|
|
550
|
+
}, {
|
|
551
|
+
key: "modulus",
|
|
552
|
+
value: function modulus(x) {
|
|
553
|
+
return this.mod(x);
|
|
554
|
+
}
|
|
555
|
+
}, {
|
|
556
|
+
key: "pow10",
|
|
557
|
+
value:
|
|
478
558
|
//#endregion
|
|
479
559
|
//#region power
|
|
480
560
|
/**
|
|
481
561
|
* @returns 10 to the power of `this`
|
|
482
562
|
*/
|
|
483
|
-
|
|
484
|
-
key: "pow10",
|
|
485
|
-
value: function pow10() {
|
|
563
|
+
function pow10() {
|
|
486
564
|
var _b, _c;
|
|
487
|
-
var
|
|
565
|
+
var thisObject = this.clone();
|
|
488
566
|
// inf & nan check
|
|
489
567
|
if (!this.isFinite()) return this.clone();
|
|
490
|
-
|
|
568
|
+
/** when 10^(t), t<0, use 10^(-t) reciprocate. */
|
|
569
|
+
if (thisObject.isneg()) {
|
|
491
570
|
// 10^(-x) = 1/(10^x)
|
|
492
|
-
|
|
493
|
-
return
|
|
571
|
+
thisObject.sign *= -1;
|
|
572
|
+
return thisObject.pow10().rec();
|
|
494
573
|
}
|
|
495
|
-
if
|
|
496
|
-
|
|
574
|
+
/**if t lessthan log10 2^1024, use fromNumber. */
|
|
575
|
+
if (thisObject.lte(308.25471555991675)) {
|
|
576
|
+
return PowiainaNum.fromNumber(Math.pow(10, thisObject.toNumber()));
|
|
497
577
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
578
|
+
/**calculate directly */
|
|
579
|
+
if (thisObject.small) {
|
|
580
|
+
if (thisObject.lt(PowiainaNum.MSI_REC)) return PowiainaNum.ONE;
|
|
581
|
+
return new PowiainaNum(Math.pow(10, Math.pow(thisObject.array[0].repeat, -1)));
|
|
501
582
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
583
|
+
/** indistinguishable above 10^^9e15 */
|
|
584
|
+
if (thisObject.gt(PowiainaNum.TETRATED_MSI)) return thisObject;
|
|
585
|
+
/**otherwise add 10^ directly */
|
|
586
|
+
thisObject.setOperator(((_c = (_b = thisObject.array[1]) === null || _b === void 0 ? void 0 : _b.repeat) !== null && _c !== void 0 ? _c : 0) + 1, 1);
|
|
587
|
+
thisObject.normalize();
|
|
588
|
+
return thisObject;
|
|
506
589
|
}
|
|
507
590
|
}, {
|
|
508
591
|
key: "pow",
|
|
@@ -512,8 +595,17 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
512
595
|
if (!other.isFinite()) return other.clone();
|
|
513
596
|
if (!this.isFinite()) return this.clone();
|
|
514
597
|
if (this.eq(10)) return other.pow10();
|
|
598
|
+
if (other.isneg()) return this.pow(other.neg()).rec();
|
|
515
599
|
if (this.isneg()) {
|
|
516
|
-
if (!other.isInt())
|
|
600
|
+
if (!other.isInt()) {
|
|
601
|
+
if (other.small) {
|
|
602
|
+
if (other.rec().div(2).eq(1)) {
|
|
603
|
+
return this.neg().pow(other).neg();
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
607
|
+
return PowiainaNum.NaN.clone();
|
|
608
|
+
}
|
|
517
609
|
var r = this.abs().pow(other);
|
|
518
610
|
r.sign = function () {
|
|
519
611
|
var a = other.mod(2).round();
|
|
@@ -541,6 +633,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
541
633
|
} else if (other.rec().mod(2).eq(1)) {
|
|
542
634
|
return this.neg().log10().mul(other).pow10().neg();
|
|
543
635
|
}
|
|
636
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
544
637
|
return PowiainaNum.NaN.clone();
|
|
545
638
|
}
|
|
546
639
|
}, {
|
|
@@ -568,7 +661,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
568
661
|
}, {
|
|
569
662
|
key: "log10",
|
|
570
663
|
value: function log10() {
|
|
571
|
-
if (this.isneg())
|
|
664
|
+
if (this.isneg()) {
|
|
665
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
666
|
+
return PowiainaNum.NaN.clone();
|
|
667
|
+
}
|
|
572
668
|
if (this.isZero()) return PowiainaNum.NEGATIVE_INFINITY.clone();
|
|
573
669
|
if (this.small) {
|
|
574
670
|
var _x = this.clone();
|
|
@@ -590,6 +686,16 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
590
686
|
var other = new PowiainaNum(base);
|
|
591
687
|
return this.log10().div(other.log10());
|
|
592
688
|
}
|
|
689
|
+
}, {
|
|
690
|
+
key: "log2",
|
|
691
|
+
value: function log2() {
|
|
692
|
+
return this.log(2);
|
|
693
|
+
}
|
|
694
|
+
}, {
|
|
695
|
+
key: "logBase",
|
|
696
|
+
value: function logBase(a) {
|
|
697
|
+
return this.log(a);
|
|
698
|
+
}
|
|
593
699
|
}, {
|
|
594
700
|
key: "ln",
|
|
595
701
|
value: function ln() {
|
|
@@ -697,8 +803,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
697
803
|
//Code from break_eternity.js
|
|
698
804
|
//Some special values, for testing: https://en.wikipedia.org/wiki/Lambert_W_function#Special_values
|
|
699
805
|
function lambertw() {
|
|
700
|
-
var
|
|
806
|
+
var princ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
807
|
+
var principal = princ;
|
|
701
808
|
if (this.lt(-0.3678794411710499)) {
|
|
809
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
702
810
|
return PowiainaNum.NaN.clone(); //complex
|
|
703
811
|
} else if (principal) {
|
|
704
812
|
if (this.abs().lt("1e-300")) return new PowiainaNum(this);else if (this.small) {
|
|
@@ -712,12 +820,13 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
712
820
|
return this.log();
|
|
713
821
|
}
|
|
714
822
|
} else {
|
|
715
|
-
if (this.sign === 1) {
|
|
823
|
+
if (this.sign === -1) {
|
|
824
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
716
825
|
return PowiainaNum.NaN.clone(); //complex
|
|
717
826
|
}
|
|
718
|
-
if (this.
|
|
827
|
+
if (this.lt(9e15)) {
|
|
719
828
|
return PowiainaNum.fromNumber(f_lambertw(this.sign * this.array[0].repeat, 1e-10, false));
|
|
720
|
-
} else if (this.
|
|
829
|
+
} else if (this.lt(PowiainaNum.E_MSI)) {
|
|
721
830
|
return d_lambertw(this, 1e-10, false);
|
|
722
831
|
} else {
|
|
723
832
|
return this.neg().rec().lambertw().neg();
|
|
@@ -736,23 +845,37 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
736
845
|
var t = this.clone();
|
|
737
846
|
var other = new PowiainaNum(other2);
|
|
738
847
|
var payl = new PowiainaNum(payload);
|
|
739
|
-
if (t.isNaN() || other.isNaN() || payl.isNaN())
|
|
848
|
+
if (t.isNaN() || other.isNaN() || payl.isNaN()) {
|
|
849
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
850
|
+
return PowiainaNum.NaN.clone();
|
|
851
|
+
}
|
|
740
852
|
if (t.eq(1)) return PowiainaNum.ONE.clone();
|
|
741
|
-
if (payl.neq(PowiainaNum.ONE)
|
|
853
|
+
if (payl.neq(PowiainaNum.ONE) && t.gte(EXP_E_REC)) {
|
|
854
|
+
other = other.add(payl.slog(t));
|
|
855
|
+
}
|
|
742
856
|
var negln;
|
|
743
857
|
if (other.isInfi() && other.sign > 0) {
|
|
744
858
|
if (t.gte(EXP_E_REC)) return PowiainaNum.POSITIVE_INFINITY.clone();
|
|
745
859
|
negln = this.log().neg();
|
|
746
860
|
return negln.lambertw().div(negln);
|
|
747
861
|
}
|
|
748
|
-
if (other.lte(-2))
|
|
862
|
+
if (other.lte(-2)) {
|
|
863
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
864
|
+
return PowiainaNum.NaN.clone();
|
|
865
|
+
}
|
|
749
866
|
if (t.isZero()) {
|
|
750
|
-
if (other.isZero())
|
|
867
|
+
if (other.isZero()) {
|
|
868
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
869
|
+
return PowiainaNum.NaN.clone();
|
|
870
|
+
}
|
|
751
871
|
if (other.gte(MSI / 2) || other.toNumber() % 2 == 0) return PowiainaNum.ZERO.clone();
|
|
752
872
|
return PowiainaNum.ONE.clone();
|
|
753
873
|
}
|
|
754
874
|
if (t.eq(PowiainaNum.ONE)) {
|
|
755
|
-
if (other.eq(PowiainaNum.ONE.neg()))
|
|
875
|
+
if (other.eq(PowiainaNum.ONE.neg())) {
|
|
876
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
877
|
+
return PowiainaNum.NaN.clone();
|
|
878
|
+
}
|
|
756
879
|
return PowiainaNum.ONE.clone();
|
|
757
880
|
}
|
|
758
881
|
if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.ZERO.clone();
|
|
@@ -826,7 +949,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
826
949
|
if (b.lt(EXP_E_REC)) {
|
|
827
950
|
var a = b.tetrate(Infinity);
|
|
828
951
|
if (x.eq(a)) return PowiainaNum.POSITIVE_INFINITY.clone();
|
|
829
|
-
if (x.gt(a))
|
|
952
|
+
if (x.gt(a)) {
|
|
953
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
954
|
+
return PowiainaNum.NaN.clone();
|
|
955
|
+
}
|
|
830
956
|
}
|
|
831
957
|
if (x.max(b).gt(PowiainaNum.PENTATED_MSI)) {
|
|
832
958
|
if (x.gt(b)) return x;
|
|
@@ -870,13 +996,17 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
870
996
|
}
|
|
871
997
|
}
|
|
872
998
|
if (x.gt(10)) return new PowiainaNum(r);
|
|
999
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
873
1000
|
return PowiainaNum.NaN.clone();
|
|
874
1001
|
}
|
|
875
1002
|
}, {
|
|
876
1003
|
key: "ssqrt",
|
|
877
1004
|
value: function ssqrt() {
|
|
878
1005
|
var x = this.clone();
|
|
879
|
-
if (x.lt(1 / EXP_E_REC))
|
|
1006
|
+
if (x.lt(1 / EXP_E_REC)) {
|
|
1007
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1008
|
+
return PowiainaNum.NaN.clone();
|
|
1009
|
+
}
|
|
880
1010
|
if (!x.isFinite()) return x;
|
|
881
1011
|
if (x.gt(PowiainaNum.TETRATED_MSI)) return x;
|
|
882
1012
|
if (x.gt(PowiainaNum.EE_MSI)) {
|
|
@@ -927,6 +1057,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
927
1057
|
if (!arrows.isInt() || arrows.lt(PowiainaNum.ZERO)) {
|
|
928
1058
|
console.warn("The arrow is <0 or not a integer, the returned function will return NaN.");
|
|
929
1059
|
return function () {
|
|
1060
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
930
1061
|
return PowiainaNum.NaN.clone();
|
|
931
1062
|
};
|
|
932
1063
|
}
|
|
@@ -952,6 +1083,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
952
1083
|
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
|
|
953
1084
|
if (t.eq(PowiainaNum.ZERO)) {
|
|
954
1085
|
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
|
|
1086
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
955
1087
|
return PowiainaNum.NaN.clone();
|
|
956
1088
|
}
|
|
957
1089
|
if (payload.neq(PowiainaNum.ONE)) other = other.add(payload.anyarrow_log(arrows)(t));
|
|
@@ -1031,6 +1163,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1031
1163
|
throw new Error(powiainaNumError + "Not implemented");
|
|
1032
1164
|
}
|
|
1033
1165
|
if (!arrow.isInt() || arrow.lt(0)) return function () {
|
|
1166
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1034
1167
|
return PowiainaNum.NaN.clone();
|
|
1035
1168
|
};
|
|
1036
1169
|
if (arrow.eq(0)) return function (base) {
|
|
@@ -1064,13 +1197,16 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1064
1197
|
return x.sub(x.getOperator(arrowsNum - 1));
|
|
1065
1198
|
}
|
|
1066
1199
|
}
|
|
1067
|
-
if (x.lt(PowiainaNum.ZERO.clone()))
|
|
1200
|
+
if (x.lt(PowiainaNum.ZERO.clone())) {
|
|
1201
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1202
|
+
return PowiainaNum.NaN.clone();
|
|
1203
|
+
}
|
|
1068
1204
|
// base^base^... = x? (? bases)
|
|
1069
1205
|
var r = 0;
|
|
1070
1206
|
// 计算x与base的差距
|
|
1071
|
-
var
|
|
1072
|
-
if (
|
|
1073
|
-
var l =
|
|
1207
|
+
var distanceLayerOf = x.getOperator(arrowsNum) - b.getOperator(arrowsNum);
|
|
1208
|
+
if (distanceLayerOf > 3) {
|
|
1209
|
+
var l = distanceLayerOf - 3;
|
|
1074
1210
|
r += l;
|
|
1075
1211
|
x.setOperator(x.getOperator(arrowsNum) - l, arrowsNum);
|
|
1076
1212
|
}
|
|
@@ -1088,6 +1224,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1088
1224
|
}
|
|
1089
1225
|
}
|
|
1090
1226
|
if (x.gt(10)) return new PowiainaNum(r);
|
|
1227
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1091
1228
|
return PowiainaNum.NaN.clone();
|
|
1092
1229
|
};
|
|
1093
1230
|
}
|
|
@@ -1112,18 +1249,18 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1112
1249
|
}
|
|
1113
1250
|
}, {
|
|
1114
1251
|
key: "pentate",
|
|
1115
|
-
value: function pentate(other) {
|
|
1116
|
-
return this.arrow(3)(other);
|
|
1252
|
+
value: function pentate(other, payload) {
|
|
1253
|
+
return this.arrow(3)(other, payload);
|
|
1117
1254
|
}
|
|
1118
1255
|
}, {
|
|
1119
1256
|
key: "hexate",
|
|
1120
|
-
value: function hexate(other) {
|
|
1121
|
-
return this.arrow(4)(other);
|
|
1257
|
+
value: function hexate(other, payload) {
|
|
1258
|
+
return this.arrow(4)(other, payload);
|
|
1122
1259
|
}
|
|
1123
1260
|
}, {
|
|
1124
1261
|
key: "pent",
|
|
1125
|
-
value: function pent(other) {
|
|
1126
|
-
return this.arrow(3)(other);
|
|
1262
|
+
value: function pent(other, payload) {
|
|
1263
|
+
return this.arrow(3)(other, payload);
|
|
1127
1264
|
}
|
|
1128
1265
|
}, {
|
|
1129
1266
|
key: "penta_log",
|
|
@@ -1131,6 +1268,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1131
1268
|
var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1132
1269
|
return this.anyarrow_log(3)(base);
|
|
1133
1270
|
}
|
|
1271
|
+
}, {
|
|
1272
|
+
key: "expansion",
|
|
1273
|
+
value:
|
|
1134
1274
|
/**
|
|
1135
1275
|
* Expansion, which is `this`{{1}}`other2`.
|
|
1136
1276
|
*
|
|
@@ -1138,15 +1278,16 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1138
1278
|
*
|
|
1139
1279
|
* @url https://googology.fandom.com/wiki/Expansion
|
|
1140
1280
|
*/
|
|
1141
|
-
|
|
1142
|
-
key: "expansion",
|
|
1143
|
-
value: function expansion(other2) {
|
|
1281
|
+
function expansion(other2) {
|
|
1144
1282
|
var other = new PowiainaNum(other2);
|
|
1145
1283
|
var t = this.clone();
|
|
1146
1284
|
if (other.lt(PowiainaNum.ZERO) || !other.isInt()) return PowiainaNum.NaN.clone();
|
|
1147
1285
|
if (other.eq(PowiainaNum.ONE)) return this.clone();
|
|
1148
1286
|
if (this.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
|
|
1149
|
-
if (!this.isInt())
|
|
1287
|
+
if (!this.isInt()) {
|
|
1288
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1289
|
+
return PowiainaNum.NaN.clone();
|
|
1290
|
+
}
|
|
1150
1291
|
if (this.eq(2)) return new PowiainaNum(4);
|
|
1151
1292
|
if (other.eq(0)) return PowiainaNum.ONE.clone();
|
|
1152
1293
|
var r;
|
|
@@ -1186,6 +1327,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1186
1327
|
var arrow = new PowiainaNum(arrow2);
|
|
1187
1328
|
var t = this.clone();
|
|
1188
1329
|
if (arrow.lt(0) || !arrow.isInt() || arrow.isNaN() || this.isNaN()) return function () {
|
|
1330
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1189
1331
|
return PowiainaNum.NaN.clone();
|
|
1190
1332
|
};
|
|
1191
1333
|
if (arrow.eq(0)) return function (other) {
|
|
@@ -1200,9 +1342,13 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1200
1342
|
var other = new PowiainaNum(other2);
|
|
1201
1343
|
var r;
|
|
1202
1344
|
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
|
|
1203
|
-
if (other.lt(PowiainaNum.ZERO))
|
|
1345
|
+
if (other.lt(PowiainaNum.ZERO)) {
|
|
1346
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1347
|
+
return PowiainaNum.NaN.clone();
|
|
1348
|
+
}
|
|
1204
1349
|
if (t.eq(PowiainaNum.ZERO)) {
|
|
1205
1350
|
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
|
|
1351
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1206
1352
|
return PowiainaNum.NaN.clone();
|
|
1207
1353
|
}
|
|
1208
1354
|
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
|
|
@@ -1388,6 +1534,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1388
1534
|
var other = new PowiainaNum(x).abs();
|
|
1389
1535
|
return this.abs().cmp(other);
|
|
1390
1536
|
}
|
|
1537
|
+
/**
|
|
1538
|
+
* -1: `this` is smaller
|
|
1539
|
+
* 0: equals
|
|
1540
|
+
* 1: `x` is smaller
|
|
1541
|
+
* 2: NaN
|
|
1542
|
+
*/
|
|
1391
1543
|
}, {
|
|
1392
1544
|
key: "compare",
|
|
1393
1545
|
value: function compare(x) {
|
|
@@ -1395,6 +1547,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1395
1547
|
if (this.isNaN() || other.isNaN()) return 2;
|
|
1396
1548
|
if (this.sign < other.sign) return -1;
|
|
1397
1549
|
if (this.sign > other.sign) return 1;
|
|
1550
|
+
var t = this;
|
|
1398
1551
|
//this.sign = other.sign
|
|
1399
1552
|
var allneg = this.sign == -1 && other.sign == -1;
|
|
1400
1553
|
if (this.small && !other.small) return -1 * (allneg ? -1 : 1);
|
|
@@ -1406,6 +1559,18 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1406
1559
|
for (var i = 0; this.array.length - 1 - i >= 0 && other.array.length - 1 - i >= 0; i++) {
|
|
1407
1560
|
var op1 = this.array[this.array.length - 1 - i];
|
|
1408
1561
|
var op2 = other.array[other.array.length - 1 - i];
|
|
1562
|
+
if (op1.repeat === Infinity && op2.repeat === Infinity) {
|
|
1563
|
+
if (t.small === other.small) return 0;
|
|
1564
|
+
return other.small ? 1 : -1;
|
|
1565
|
+
}
|
|
1566
|
+
if (op1.repeat === Infinity) {
|
|
1567
|
+
result = 1;
|
|
1568
|
+
break;
|
|
1569
|
+
}
|
|
1570
|
+
if (op2.repeat === Infinity) {
|
|
1571
|
+
result = -1;
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1409
1574
|
var cmp = compareTuples([op1.megota, op1.expans, op1.arrow, op1.repeat], [op2.megota, op2.expans, op2.arrow, op2.repeat]);
|
|
1410
1575
|
if (cmp == 1) {
|
|
1411
1576
|
result = 1;
|
|
@@ -1453,6 +1618,16 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1453
1618
|
var t = this.cmp(other);
|
|
1454
1619
|
return t == 0 || t == 1;
|
|
1455
1620
|
}
|
|
1621
|
+
}, {
|
|
1622
|
+
key: "equals",
|
|
1623
|
+
value: function equals(other) {
|
|
1624
|
+
return this.eq(other);
|
|
1625
|
+
}
|
|
1626
|
+
}, {
|
|
1627
|
+
key: "notEquals",
|
|
1628
|
+
value: function notEquals(other) {
|
|
1629
|
+
return this.neq(other);
|
|
1630
|
+
}
|
|
1456
1631
|
}, {
|
|
1457
1632
|
key: "eq_tolerance",
|
|
1458
1633
|
value: function eq_tolerance(value) {
|
|
@@ -1462,6 +1637,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1462
1637
|
}
|
|
1463
1638
|
//#endregion
|
|
1464
1639
|
//#region geometry
|
|
1640
|
+
/**this function is indistinguishable above 4503599627370496*/
|
|
1465
1641
|
}, {
|
|
1466
1642
|
key: "sin",
|
|
1467
1643
|
value: function sin() {
|
|
@@ -1514,6 +1690,16 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1514
1690
|
a.small = !a.small;
|
|
1515
1691
|
return a;
|
|
1516
1692
|
}
|
|
1693
|
+
}, {
|
|
1694
|
+
key: "recip",
|
|
1695
|
+
value: function recip() {
|
|
1696
|
+
return this.rec();
|
|
1697
|
+
}
|
|
1698
|
+
}, {
|
|
1699
|
+
key: "reciprocate",
|
|
1700
|
+
value: function reciprocate() {
|
|
1701
|
+
return this.rec();
|
|
1702
|
+
}
|
|
1517
1703
|
}, {
|
|
1518
1704
|
key: "floor",
|
|
1519
1705
|
value: function floor() {
|
|
@@ -1554,6 +1740,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1554
1740
|
r.sign = this.sign;
|
|
1555
1741
|
return r;
|
|
1556
1742
|
}
|
|
1743
|
+
}, {
|
|
1744
|
+
key: "trunc",
|
|
1745
|
+
value:
|
|
1557
1746
|
/**
|
|
1558
1747
|
* Work like `Math.trunc`,
|
|
1559
1748
|
*
|
|
@@ -1566,15 +1755,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1566
1755
|
* new PowiainaNum(-1.114514).trunc() == new PowiainaNum(-1)
|
|
1567
1756
|
* @returns
|
|
1568
1757
|
*/
|
|
1569
|
-
|
|
1570
|
-
key: "trunc",
|
|
1571
|
-
value: function trunc() {
|
|
1758
|
+
function trunc() {
|
|
1572
1759
|
var y = this.clone();
|
|
1573
1760
|
return y.gte(0) ? y.floor() : y.ceil();
|
|
1574
1761
|
}
|
|
1575
|
-
/**
|
|
1576
|
-
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
1577
|
-
*/
|
|
1578
1762
|
}, {
|
|
1579
1763
|
key: "isNaN",
|
|
1580
1764
|
value: function (_isNaN) {
|
|
@@ -1637,10 +1821,164 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1637
1821
|
value: function isneg() {
|
|
1638
1822
|
return this.sign < 0;
|
|
1639
1823
|
}
|
|
1824
|
+
}, {
|
|
1825
|
+
key: "getOperatorIndex",
|
|
1826
|
+
value:
|
|
1827
|
+
//#endregion
|
|
1828
|
+
//#region operators
|
|
1829
|
+
/**
|
|
1830
|
+
* @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.
|
|
1831
|
+
*/
|
|
1832
|
+
function getOperatorIndex(arrow) {
|
|
1833
|
+
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1834
|
+
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1835
|
+
for (var i = 0; i < this.array.length; i++) {
|
|
1836
|
+
var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
|
|
1837
|
+
if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
|
|
1838
|
+
if (cmp == 1) return i - 0.5; // It's between [xx, xx,xx*,?,*xx]!
|
|
1839
|
+
}
|
|
1840
|
+
return this.array.length - 0.5;
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* @returns number repeats of operators with given arguments.
|
|
1844
|
+
*/
|
|
1845
|
+
}, {
|
|
1846
|
+
key: "getOperator",
|
|
1847
|
+
value: function getOperator(arrow) {
|
|
1848
|
+
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1849
|
+
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1850
|
+
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1851
|
+
if (!this.array[index]) return 0;
|
|
1852
|
+
return this.array[index].repeat;
|
|
1853
|
+
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Modify the repeat of operator
|
|
1856
|
+
* @param number val the repeat of operator will modify to array.
|
|
1857
|
+
* @returns bool Is the operators array changed?
|
|
1858
|
+
*/
|
|
1859
|
+
}, {
|
|
1860
|
+
key: "setOperator",
|
|
1861
|
+
value: function setOperator(val, arrow) {
|
|
1862
|
+
var expans = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1863
|
+
var megota = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
1864
|
+
// if (arrow!=0&&val==0) return false;
|
|
1865
|
+
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1866
|
+
if (!this.array[index]) {
|
|
1867
|
+
this.array.splice(Math.ceil(index), 0, {
|
|
1868
|
+
arrow: arrow,
|
|
1869
|
+
expans: expans,
|
|
1870
|
+
megota: megota,
|
|
1871
|
+
valuereplaced: expans === Infinity ? 1 : arrow == Infinity ? 0 : -1,
|
|
1872
|
+
repeat: val
|
|
1873
|
+
});
|
|
1874
|
+
return true;
|
|
1875
|
+
}
|
|
1876
|
+
this.array[index].repeat = val;
|
|
1877
|
+
// this.normalize()
|
|
1878
|
+
return false;
|
|
1879
|
+
}
|
|
1880
|
+
//#endregion
|
|
1881
|
+
//#region converters
|
|
1882
|
+
/**
|
|
1883
|
+
* Convert `this` to Javascript `number`
|
|
1884
|
+
*
|
|
1885
|
+
* returns `Infinity` when the number is greater than `Number.MAX_VALUE`
|
|
1886
|
+
*/
|
|
1887
|
+
}, {
|
|
1888
|
+
key: "toNumber",
|
|
1889
|
+
value: function toNumber() {
|
|
1890
|
+
if (this.sign == -1) return -this.neg().toNumber();
|
|
1891
|
+
if (this.small) return 1 / this.rec().toNumber();
|
|
1892
|
+
if (this.array.length > 2) return Infinity;
|
|
1893
|
+
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));
|
|
1894
|
+
return NaN;
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Convert `this` to a string
|
|
1898
|
+
*/
|
|
1899
|
+
}, {
|
|
1900
|
+
key: "toString_core",
|
|
1901
|
+
value: function toString_core() {
|
|
1902
|
+
if (this.isNaN()) return "NaN";
|
|
1903
|
+
if (this.sign == -1) return "-".concat(this.neg().toString());
|
|
1904
|
+
if (this.small) {
|
|
1905
|
+
if (this.isZero()) return "0";
|
|
1906
|
+
return "/".concat(this.rec().toString());
|
|
1907
|
+
}
|
|
1908
|
+
if (this.isInfi()) return "Infinity";
|
|
1909
|
+
// P^a (10{arrow,expans,megota})^repeation base
|
|
1910
|
+
var res = "";
|
|
1911
|
+
if (!this.layer) res += "";else if (this.layer < 3) res += "P".repeat(this.layer);else res += "P^" + this.layer + " ";
|
|
1912
|
+
for (var i = this.array.length - 1; i >= 0; i--) {
|
|
1913
|
+
var oper = this.array[i];
|
|
1914
|
+
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) : "", "}");
|
|
1915
|
+
if (oper.arrow == 1 && oper.expans == 1 && oper.megota == 1 && oper.repeat < 5) {
|
|
1916
|
+
calc = "e".repeat(oper.repeat);
|
|
1917
|
+
} else if (oper.arrow == 0 && oper.expans == 1 && oper.megota == 1) {
|
|
1918
|
+
calc = oper.repeat.toString();
|
|
1919
|
+
} else if (oper.repeat > 1) {
|
|
1920
|
+
calc = "(".concat(calc, ")^").concat(oper.repeat, " ");
|
|
1921
|
+
} else {
|
|
1922
|
+
calc = "".concat(calc);
|
|
1923
|
+
}
|
|
1924
|
+
res += "".concat(calc);
|
|
1925
|
+
}
|
|
1926
|
+
return res;
|
|
1927
|
+
}
|
|
1928
|
+
}, {
|
|
1929
|
+
key: "toString",
|
|
1930
|
+
value: function toString() {
|
|
1931
|
+
try {
|
|
1932
|
+
return this.toString_core();
|
|
1933
|
+
} catch (_b) {
|
|
1934
|
+
console.error("Checked error when converting to string");
|
|
1935
|
+
return "NaN";
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
}, {
|
|
1939
|
+
key: "toJSON",
|
|
1940
|
+
value:
|
|
1941
|
+
/**
|
|
1942
|
+
* Convert `this` to a JSON object
|
|
1943
|
+
* @returns a JSON object
|
|
1944
|
+
*/
|
|
1945
|
+
function toJSON() {
|
|
1946
|
+
return "PN" + this.toString();
|
|
1947
|
+
}
|
|
1948
|
+
}, {
|
|
1949
|
+
key: "arr01",
|
|
1950
|
+
get:
|
|
1951
|
+
/**
|
|
1952
|
+
* A property array value for version 0.1.x PowiainaNum.
|
|
1953
|
+
*/
|
|
1954
|
+
function get() {
|
|
1955
|
+
var res = [0];
|
|
1956
|
+
for (var i = 0; i < this.array.length; i++) {
|
|
1957
|
+
if (i == 0) res[0] = this.array[i].repeat;else {
|
|
1958
|
+
// @ts-ignore
|
|
1959
|
+
res[i] = [0, 0, 0, 0];
|
|
1960
|
+
// @ts-ignore
|
|
1961
|
+
res[i][0] = this.array[i].arrow == Infinity ? "x" : this.array[i].arrow;
|
|
1962
|
+
// @ts-ignore
|
|
1963
|
+
res[i][1] = this.array[i].repeat;
|
|
1964
|
+
// @ts-ignore
|
|
1965
|
+
res[i][2] = this.array[i].expans == Infinity ? "x" : this.array[i].expans;
|
|
1966
|
+
// @ts-ignore
|
|
1967
|
+
res[i][3] = this.array[i].megota;
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
return res;
|
|
1971
|
+
}
|
|
1972
|
+
//#endregion
|
|
1973
|
+
//#region useless functions
|
|
1974
|
+
/**
|
|
1975
|
+
* This function is for NaNe308, if you want to calculate G(x), use this function directly.
|
|
1976
|
+
*/
|
|
1640
1977
|
}, {
|
|
1641
1978
|
key: "normalize",
|
|
1642
1979
|
value:
|
|
1643
1980
|
//#endregion
|
|
1981
|
+
//#region other functions
|
|
1644
1982
|
/**
|
|
1645
1983
|
* Normalize functions will make this number convert into standard format.(it also change `this`, like [].sort)
|
|
1646
1984
|
* @returns normalized number
|
|
@@ -1649,9 +1987,14 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1649
1987
|
//TODO: normalize
|
|
1650
1988
|
var renormalize = true;
|
|
1651
1989
|
var x = this;
|
|
1652
|
-
|
|
1990
|
+
if (this.array === undefined) {
|
|
1991
|
+
x.array = [newOperator(NaN, 0, 1, 1)];
|
|
1992
|
+
}
|
|
1993
|
+
if (this.sign === undefined) this.sign = 0;
|
|
1994
|
+
if (this.layer === undefined) this.layer = 0;
|
|
1995
|
+
for (var i = 0; i < this.array.length; i++) {
|
|
1653
1996
|
// Check what is infinity
|
|
1654
|
-
if (this.array[
|
|
1997
|
+
if (this.array[i].repeat == Infinity) {
|
|
1655
1998
|
this.array = [{
|
|
1656
1999
|
arrow: 0,
|
|
1657
2000
|
expans: 1,
|
|
@@ -1662,8 +2005,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1662
2005
|
return this;
|
|
1663
2006
|
}
|
|
1664
2007
|
}
|
|
1665
|
-
for (var
|
|
1666
|
-
var e = x.array[
|
|
2008
|
+
for (var _i = 1; _i < x.array.length; ++_i) {
|
|
2009
|
+
var e = x.array[_i];
|
|
1667
2010
|
if (e.arrow === null || e.arrow === undefined) {
|
|
1668
2011
|
e.arrow = 0;
|
|
1669
2012
|
}
|
|
@@ -1694,28 +2037,28 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1694
2037
|
renormalize = false;
|
|
1695
2038
|
// Sort arrays.
|
|
1696
2039
|
this.array.sort(arraySortFunction);
|
|
1697
|
-
for (
|
|
1698
|
-
if (x.array[
|
|
2040
|
+
for (var _i2 = 1; _i2 < x.array.length - 1; ++_i2) {
|
|
2041
|
+
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) {
|
|
1699
2042
|
// same array's merge
|
|
1700
|
-
x.array[
|
|
1701
|
-
x.array.splice(
|
|
1702
|
-
--
|
|
2043
|
+
x.array[_i2].repeat += x.array[_i2 + 1].repeat;
|
|
2044
|
+
x.array.splice(_i2 + 1, 1);
|
|
2045
|
+
--_i2;
|
|
1703
2046
|
renormalize = true;
|
|
1704
2047
|
}
|
|
1705
2048
|
}
|
|
1706
|
-
for (
|
|
2049
|
+
for (var _i3 = 1; _i3 < x.array.length; ++_i3) {
|
|
1707
2050
|
// If there is a 0 repeat operator, remove it.
|
|
1708
|
-
if (x.array[
|
|
1709
|
-
x.array.splice(
|
|
1710
|
-
--
|
|
2051
|
+
if (x.array[_i3].arrow !== 0 && (x.array[_i3].repeat === 0 || x.array[_i3].repeat === null || x.array[_i3].repeat === undefined)) {
|
|
2052
|
+
x.array.splice(_i3, 1);
|
|
2053
|
+
--_i3;
|
|
1711
2054
|
continue;
|
|
1712
2055
|
}
|
|
1713
2056
|
// If there is a operator which arrow 0 and brace count >=2
|
|
1714
2057
|
// replace it as arrow replacement operaotr
|
|
1715
|
-
if (x.array[
|
|
1716
|
-
x.array[
|
|
1717
|
-
x.array[
|
|
1718
|
-
x.array[
|
|
2058
|
+
if (x.array[_i3].arrow == 0 && x.array[_i3].expans >= 2) {
|
|
2059
|
+
x.array[_i3].arrow = Infinity;
|
|
2060
|
+
x.array[_i3].valuereplaced = 0;
|
|
2061
|
+
x.array[_i3].expans = x.array[_i3].expans - 1;
|
|
1719
2062
|
}
|
|
1720
2063
|
}
|
|
1721
2064
|
if (x.array.length > PowiainaNum.maxOps) x.array.splice(1, x.array.length - PowiainaNum.maxOps); // max operators check
|
|
@@ -1745,6 +2088,11 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1745
2088
|
this.small = !this.small;
|
|
1746
2089
|
renormalize = true;
|
|
1747
2090
|
}
|
|
2091
|
+
// for a = 1, small should false.
|
|
2092
|
+
if (this.array.length == 1 && this.array[0].repeat == 1 && this.small) {
|
|
2093
|
+
this.small = false;
|
|
2094
|
+
renormalize = true;
|
|
2095
|
+
}
|
|
1748
2096
|
// for any 10{X>9e15}10, replace into 10{!}X;
|
|
1749
2097
|
if (this.array.length >= 2 && this.array[1].arrow >= MSI) {
|
|
1750
2098
|
this.array[0].repeat = this.array[1].arrow;
|
|
@@ -1800,61 +2148,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1800
2148
|
} while (renormalize);
|
|
1801
2149
|
return this;
|
|
1802
2150
|
}
|
|
1803
|
-
//#region operators
|
|
1804
|
-
/**
|
|
1805
|
-
* @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.
|
|
1806
|
-
*/
|
|
1807
|
-
}, {
|
|
1808
|
-
key: "getOperatorIndex",
|
|
1809
|
-
value: function getOperatorIndex(arrow) {
|
|
1810
|
-
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1811
|
-
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1812
|
-
for (var i = 0; i < this.array.length; i++) {
|
|
1813
|
-
var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
|
|
1814
|
-
if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
|
|
1815
|
-
if (cmp == 1) return i - 0.5; // It's between [xx, xx,xx*,?,*xx]!
|
|
1816
|
-
}
|
|
1817
|
-
return this.array.length - 0.5;
|
|
1818
|
-
}
|
|
1819
|
-
/**
|
|
1820
|
-
* @returns number repeats of operators with given arguments.
|
|
1821
|
-
*/
|
|
1822
|
-
}, {
|
|
1823
|
-
key: "getOperator",
|
|
1824
|
-
value: function getOperator(arrow) {
|
|
1825
|
-
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1826
|
-
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1827
|
-
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1828
|
-
if (!this.array[index]) return 0;
|
|
1829
|
-
return this.array[index].repeat;
|
|
1830
|
-
}
|
|
1831
|
-
/**
|
|
1832
|
-
* Modify the repeat of operator
|
|
1833
|
-
* @param number val the repeat of operator will modify to array.
|
|
1834
|
-
* @returns bool Is the operators array changed?
|
|
1835
|
-
*/
|
|
1836
|
-
}, {
|
|
1837
|
-
key: "setOperator",
|
|
1838
|
-
value: function setOperator(val, arrow) {
|
|
1839
|
-
var expans = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1840
|
-
var megota = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
1841
|
-
// if (arrow!=0&&val==0) return false;
|
|
1842
|
-
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1843
|
-
if (!this.array[index]) {
|
|
1844
|
-
this.array.splice(Math.ceil(index), 0, {
|
|
1845
|
-
arrow: arrow,
|
|
1846
|
-
expans: expans,
|
|
1847
|
-
megota: megota,
|
|
1848
|
-
valuereplaced: expans === Infinity ? 1 : arrow == Infinity ? 0 : -1,
|
|
1849
|
-
repeat: val
|
|
1850
|
-
});
|
|
1851
|
-
return true;
|
|
1852
|
-
}
|
|
1853
|
-
this.array[index].repeat = val;
|
|
1854
|
-
// this.normalize()
|
|
1855
|
-
return false;
|
|
1856
|
-
}
|
|
1857
|
-
//#endregion
|
|
1858
2151
|
/**
|
|
1859
2152
|
* @returns a PowiainaNum object which deep copied from `this` object.
|
|
1860
2153
|
*/
|
|
@@ -1873,6 +2166,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1873
2166
|
}, {
|
|
1874
2167
|
key: "resetFromObject",
|
|
1875
2168
|
value: function resetFromObject(powlikeObject) {
|
|
2169
|
+
if (!powlikeObject.array) {
|
|
2170
|
+
return;
|
|
2171
|
+
}
|
|
1876
2172
|
this.array = [];
|
|
1877
2173
|
for (var i = 0; i < powlikeObject.array.length; i++) {
|
|
1878
2174
|
this.array[i] = {
|
|
@@ -1888,107 +2184,56 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1888
2184
|
this.layer = powlikeObject.layer;
|
|
1889
2185
|
return this;
|
|
1890
2186
|
}
|
|
1891
|
-
//#region converters
|
|
1892
|
-
/**
|
|
1893
|
-
* Convert `this` to Javascript `number`
|
|
1894
|
-
*
|
|
1895
|
-
* returns `Infinity` when the number is greater than `Number.MAX_VALUE`
|
|
1896
|
-
*/
|
|
1897
|
-
}, {
|
|
1898
|
-
key: "toNumber",
|
|
1899
|
-
value: function toNumber() {
|
|
1900
|
-
if (this.sign == -1) return -this.neg().toNumber();
|
|
1901
|
-
if (this.small) return 1 / this.rec().toNumber();
|
|
1902
|
-
if (this.array.length > 2) return Infinity;
|
|
1903
|
-
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));
|
|
1904
|
-
return NaN;
|
|
1905
|
-
}
|
|
1906
|
-
/**
|
|
1907
|
-
* Convert `this` to a string
|
|
1908
|
-
*/
|
|
1909
|
-
}, {
|
|
1910
|
-
key: "toString",
|
|
1911
|
-
value: function toString() {
|
|
1912
|
-
if (this.isNaN()) return "NaN";
|
|
1913
|
-
if (this.sign == -1) return "-".concat(this.neg().toString());
|
|
1914
|
-
if (this.small) {
|
|
1915
|
-
if (this.isZero()) return "0";
|
|
1916
|
-
return "/".concat(this.rec().toString());
|
|
1917
|
-
}
|
|
1918
|
-
if (this.isInfi()) return "Infinity";
|
|
1919
|
-
// P^a (10{arrow,expans,megota})^repeation base
|
|
1920
|
-
var res = "";
|
|
1921
|
-
if (!this.layer) res += "";else if (this.layer < 3) res += "P".repeat(this.layer);else res += "P^" + this.layer + " ";
|
|
1922
|
-
for (var i = this.array.length - 1; i >= 0; i--) {
|
|
1923
|
-
var oper = this.array[i];
|
|
1924
|
-
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) : "", "}");
|
|
1925
|
-
if (oper.arrow == 1 && oper.expans == 1 && oper.megota == 1 && oper.repeat < 5) {
|
|
1926
|
-
calc = "e".repeat(oper.repeat);
|
|
1927
|
-
} else if (oper.arrow == 0 && oper.expans == 1 && oper.megota == 1) {
|
|
1928
|
-
calc = oper.repeat.toString();
|
|
1929
|
-
} else if (oper.repeat > 1) {
|
|
1930
|
-
calc = "(".concat(calc, ")^").concat(oper.repeat, " ");
|
|
1931
|
-
} else {
|
|
1932
|
-
calc = "".concat(calc);
|
|
1933
|
-
}
|
|
1934
|
-
res += "".concat(calc);
|
|
1935
|
-
}
|
|
1936
|
-
return res;
|
|
1937
|
-
}
|
|
1938
|
-
}, {
|
|
1939
|
-
key: "toJSON",
|
|
1940
|
-
value:
|
|
1941
|
-
/**
|
|
1942
|
-
* Convert `this` to a JSON object
|
|
1943
|
-
* @returns a JSON object
|
|
1944
|
-
*/
|
|
1945
|
-
function toJSON() {
|
|
1946
|
-
return "PN" + this.toString();
|
|
1947
|
-
}
|
|
1948
|
-
}, {
|
|
1949
|
-
key: "arr01",
|
|
1950
|
-
get:
|
|
1951
|
-
/**
|
|
1952
|
-
* A property array value for version 0.1.x PowiainaNum.
|
|
1953
|
-
*/
|
|
1954
|
-
function get() {
|
|
1955
|
-
var res = [0];
|
|
1956
|
-
for (var i = 0; i < this.array.length; i++) {
|
|
1957
|
-
if (i == 0) res[0] = this.array[i].repeat;else {
|
|
1958
|
-
// @ts-ignore
|
|
1959
|
-
res[i] = [0, 0, 0, 0];
|
|
1960
|
-
// @ts-ignore
|
|
1961
|
-
res[i][0] = this.array[i].arrow == Infinity ? "x" : this.array[i].arrow;
|
|
1962
|
-
// @ts-ignore
|
|
1963
|
-
res[i][1] = this.array[i].repeat;
|
|
1964
|
-
// @ts-ignore
|
|
1965
|
-
res[i][2] = this.array[i].expans == Infinity ? "x" : this.array[i].expans;
|
|
1966
|
-
// @ts-ignore
|
|
1967
|
-
res[i][3] = this.array[i].megota;
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1970
|
-
return res;
|
|
1971
|
-
}
|
|
1972
2187
|
}], [{
|
|
1973
2188
|
key: "add",
|
|
1974
2189
|
value: function add(t, other) {
|
|
1975
2190
|
return new PowiainaNum(t).add(other);
|
|
1976
2191
|
}
|
|
2192
|
+
}, {
|
|
2193
|
+
key: "plus",
|
|
2194
|
+
value: function plus(t, other) {
|
|
2195
|
+
return new PowiainaNum(t).add(other);
|
|
2196
|
+
}
|
|
1977
2197
|
}, {
|
|
1978
2198
|
key: "sub",
|
|
1979
2199
|
value: function sub(t, other) {
|
|
1980
2200
|
return new PowiainaNum(t).sub(other);
|
|
1981
2201
|
}
|
|
2202
|
+
}, {
|
|
2203
|
+
key: "minus",
|
|
2204
|
+
value: function minus(t, other) {
|
|
2205
|
+
return new PowiainaNum(t).sub(other);
|
|
2206
|
+
}
|
|
1982
2207
|
}, {
|
|
1983
2208
|
key: "mul",
|
|
1984
2209
|
value: function mul(t, other) {
|
|
1985
2210
|
return new PowiainaNum(t).mul(other);
|
|
1986
2211
|
}
|
|
2212
|
+
}, {
|
|
2213
|
+
key: "times",
|
|
2214
|
+
value: function times(t, other) {
|
|
2215
|
+
return new PowiainaNum(t).mul(other);
|
|
2216
|
+
}
|
|
1987
2217
|
}, {
|
|
1988
2218
|
key: "div",
|
|
1989
2219
|
value: function div(t, other) {
|
|
1990
2220
|
return new PowiainaNum(t).div(other);
|
|
1991
2221
|
}
|
|
2222
|
+
}, {
|
|
2223
|
+
key: "divide",
|
|
2224
|
+
value: function divide(t, other) {
|
|
2225
|
+
return new PowiainaNum(t).div(other);
|
|
2226
|
+
}
|
|
2227
|
+
}, {
|
|
2228
|
+
key: "mod",
|
|
2229
|
+
value: function mod(x, y) {
|
|
2230
|
+
return new PowiainaNum(x).mod(y);
|
|
2231
|
+
}
|
|
2232
|
+
}, {
|
|
2233
|
+
key: "modulus",
|
|
2234
|
+
value: function modulus(x, y) {
|
|
2235
|
+
return new PowiainaNum(x).mod(y);
|
|
2236
|
+
}
|
|
1992
2237
|
}, {
|
|
1993
2238
|
key: "pow",
|
|
1994
2239
|
value: function pow(t, other) {
|
|
@@ -2020,6 +2265,17 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2020
2265
|
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.E;
|
|
2021
2266
|
return new PowiainaNum(t).log(base);
|
|
2022
2267
|
}
|
|
2268
|
+
}, {
|
|
2269
|
+
key: "log2",
|
|
2270
|
+
value: function log2(t) {
|
|
2271
|
+
return new PowiainaNum(t).log2();
|
|
2272
|
+
}
|
|
2273
|
+
}, {
|
|
2274
|
+
key: "logBase",
|
|
2275
|
+
value: function logBase(t) {
|
|
2276
|
+
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.E;
|
|
2277
|
+
return new PowiainaNum(t).log(base);
|
|
2278
|
+
}
|
|
2023
2279
|
}, {
|
|
2024
2280
|
key: "pLog10",
|
|
2025
2281
|
value: function pLog10(t) {
|
|
@@ -2171,6 +2427,27 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2171
2427
|
};
|
|
2172
2428
|
}
|
|
2173
2429
|
}
|
|
2430
|
+
}, {
|
|
2431
|
+
key: "pentate",
|
|
2432
|
+
value: function pentate(x, other, payload) {
|
|
2433
|
+
return new PowiainaNum(x).arrow(3)(other, payload);
|
|
2434
|
+
}
|
|
2435
|
+
}, {
|
|
2436
|
+
key: "hexate",
|
|
2437
|
+
value: function hexate(x, other, payload) {
|
|
2438
|
+
return new PowiainaNum(x).arrow(4)(other, payload);
|
|
2439
|
+
}
|
|
2440
|
+
}, {
|
|
2441
|
+
key: "pent",
|
|
2442
|
+
value: function pent(x, other, payload) {
|
|
2443
|
+
return new PowiainaNum(x).arrow(3)(other, payload);
|
|
2444
|
+
}
|
|
2445
|
+
}, {
|
|
2446
|
+
key: "penta_log",
|
|
2447
|
+
value: function penta_log(x) {
|
|
2448
|
+
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
2449
|
+
return new PowiainaNum(x).anyarrow_log(3)(base);
|
|
2450
|
+
}
|
|
2174
2451
|
}, {
|
|
2175
2452
|
key: "expansion",
|
|
2176
2453
|
value: function expansion(t, other) {
|
|
@@ -2226,7 +2503,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2226
2503
|
if (base.eq(1)) return new PowiainaNum(1);
|
|
2227
2504
|
if (power.eq(1)) return new PowiainaNum(base);
|
|
2228
2505
|
if (power.isZero()) return new PowiainaNum(1);
|
|
2229
|
-
if (base.lt(0))
|
|
2506
|
+
if (base.lt(0)) {
|
|
2507
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
2508
|
+
return PowiainaNum.NaN.clone();
|
|
2509
|
+
}
|
|
2230
2510
|
// // check infinite
|
|
2231
2511
|
// let sufpowiaina = args.slice(4);
|
|
2232
2512
|
// if (sufpowiaina.filter((f) => new PowiainaNum(f).gte(2)).length > 0) {
|
|
@@ -2269,9 +2549,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2269
2549
|
if (a == 0 && e == 1 && m > 1) {
|
|
2270
2550
|
return [1, 1 / 0, m - 1];
|
|
2271
2551
|
}
|
|
2272
|
-
if (e == 0 && m > 1) {
|
|
2273
|
-
return [1, 1 / 0, m - 1];
|
|
2274
|
-
}
|
|
2275
2552
|
return [a, e, m];
|
|
2276
2553
|
}
|
|
2277
2554
|
if (megota.gt(MSI)) {
|
|
@@ -2285,8 +2562,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2285
2562
|
return x.toString();
|
|
2286
2563
|
}
|
|
2287
2564
|
function getMSIForm(arrow, expans, megota) {
|
|
2288
|
-
|
|
2289
|
-
return "10{".concat(infToBang(conv[0]), ",").concat(infToBang(conv[1]), ",").concat(conv[2], "}").concat(MSI);
|
|
2565
|
+
return "10{".concat(infToBang(arrow), ",").concat(infToBang(expans), ",").concat(megota, "}").concat(MSI);
|
|
2290
2566
|
}
|
|
2291
2567
|
var t = base.clone();
|
|
2292
2568
|
var arrows = new PowiainaNum(readArg(0));
|
|
@@ -2294,20 +2570,13 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2294
2570
|
var _r, _r2;
|
|
2295
2571
|
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
2296
2572
|
console.log("".concat("-".repeat(depth), " {").concat(base2, ",").concat(power2, ",").concat(arrow2, ",").concat(expans2, ",").concat(megota2, "}"));
|
|
2297
|
-
if (depth >= 200) {
|
|
2298
|
-
return new PowiainaNum({
|
|
2299
|
-
layer: 0,
|
|
2300
|
-
array: [newOperator(10), newOperator(1, new PowiainaNum(arrow2).clampMax(MSI).toNumber(), new PowiainaNum(expans2).clampMax(MSI).toNumber(), new PowiainaNum(megota2).clampMax(MSI).toNumber())],
|
|
2301
|
-
sign: 1,
|
|
2302
|
-
small: false
|
|
2303
|
-
}).normalize();
|
|
2304
|
-
}
|
|
2305
2573
|
var other = new PowiainaNum(other2);
|
|
2306
2574
|
var r;
|
|
2307
2575
|
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
|
|
2308
2576
|
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
|
|
2309
2577
|
if (t.eq(PowiainaNum.ZERO)) {
|
|
2310
2578
|
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
|
|
2579
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
2311
2580
|
return PowiainaNum.NaN.clone();
|
|
2312
2581
|
}
|
|
2313
2582
|
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
|
|
@@ -2319,7 +2588,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2319
2588
|
}
|
|
2320
2589
|
if (expans.eq(0)) {
|
|
2321
2590
|
return PowiainaNum.BEAF(t, t, t, power, megota.sub(1), powiaina2, depth + 1);
|
|
2322
|
-
// {this, this, power,
|
|
2591
|
+
// {this, this, this, power, megota-1}
|
|
2323
2592
|
}
|
|
2324
2593
|
if (megota.eq(0)) {
|
|
2325
2594
|
return PowiainaNum.BEAF(t, t, t, t, expans, new PowiainaNum(powiaina2).sub(1), depth + 1);
|
|
@@ -2438,6 +2707,84 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2438
2707
|
value: function clampMax() {
|
|
2439
2708
|
return PowiainaNum.min.apply(PowiainaNum, arguments);
|
|
2440
2709
|
}
|
|
2710
|
+
}, {
|
|
2711
|
+
key: "eq",
|
|
2712
|
+
value: function eq(a, o) {
|
|
2713
|
+
return new PowiainaNum(a).eq(o);
|
|
2714
|
+
}
|
|
2715
|
+
}, {
|
|
2716
|
+
key: "equals",
|
|
2717
|
+
value: function equals(a, o) {
|
|
2718
|
+
return new PowiainaNum(a).eq(o);
|
|
2719
|
+
}
|
|
2720
|
+
}, {
|
|
2721
|
+
key: "neq",
|
|
2722
|
+
value: function neq(a, o) {
|
|
2723
|
+
return new PowiainaNum(a).neq(o);
|
|
2724
|
+
}
|
|
2725
|
+
}, {
|
|
2726
|
+
key: "notEquals",
|
|
2727
|
+
value: function notEquals(a, o) {
|
|
2728
|
+
return new PowiainaNum(a).notEquals(o);
|
|
2729
|
+
}
|
|
2730
|
+
}, {
|
|
2731
|
+
key: "lt",
|
|
2732
|
+
value: function lt(a, o) {
|
|
2733
|
+
return new PowiainaNum(a).lt(o);
|
|
2734
|
+
}
|
|
2735
|
+
}, {
|
|
2736
|
+
key: "gt",
|
|
2737
|
+
value: function gt(a, o) {
|
|
2738
|
+
return new PowiainaNum(a).gt(o);
|
|
2739
|
+
}
|
|
2740
|
+
}, {
|
|
2741
|
+
key: "lte",
|
|
2742
|
+
value: function lte(a, o) {
|
|
2743
|
+
return new PowiainaNum(a).lte(o);
|
|
2744
|
+
}
|
|
2745
|
+
}, {
|
|
2746
|
+
key: "gte",
|
|
2747
|
+
value: function gte(a, o) {
|
|
2748
|
+
return new PowiainaNum(a).gte(o);
|
|
2749
|
+
}
|
|
2750
|
+
}, {
|
|
2751
|
+
key: "rec",
|
|
2752
|
+
value: function rec(t) {
|
|
2753
|
+
return new PowiainaNum(t).rec();
|
|
2754
|
+
}
|
|
2755
|
+
}, {
|
|
2756
|
+
key: "recip",
|
|
2757
|
+
value: function recip(t) {
|
|
2758
|
+
return new PowiainaNum(t).rec();
|
|
2759
|
+
}
|
|
2760
|
+
}, {
|
|
2761
|
+
key: "reciprocate",
|
|
2762
|
+
value: function reciprocate(t) {
|
|
2763
|
+
return new PowiainaNum(t).rec();
|
|
2764
|
+
}
|
|
2765
|
+
}, {
|
|
2766
|
+
key: "floor",
|
|
2767
|
+
value: function floor(x) {
|
|
2768
|
+
return new PowiainaNum(x).floor();
|
|
2769
|
+
}
|
|
2770
|
+
}, {
|
|
2771
|
+
key: "ceil",
|
|
2772
|
+
value: function ceil(x) {
|
|
2773
|
+
return new PowiainaNum(x).ceil();
|
|
2774
|
+
}
|
|
2775
|
+
}, {
|
|
2776
|
+
key: "round",
|
|
2777
|
+
value: function round(x) {
|
|
2778
|
+
return new PowiainaNum(x).round();
|
|
2779
|
+
}
|
|
2780
|
+
}, {
|
|
2781
|
+
key: "trunc",
|
|
2782
|
+
value: function trunc(x) {
|
|
2783
|
+
return new PowiainaNum(x).trunc();
|
|
2784
|
+
}
|
|
2785
|
+
/**
|
|
2786
|
+
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
2787
|
+
*/
|
|
2441
2788
|
}, {
|
|
2442
2789
|
key: "sign",
|
|
2443
2790
|
value: function sign(a) {
|
|
@@ -2451,7 +2798,19 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2451
2798
|
}, {
|
|
2452
2799
|
key: "fromNumber",
|
|
2453
2800
|
value: function fromNumber(x) {
|
|
2454
|
-
var obj = new PowiainaNum();
|
|
2801
|
+
var obj = new PowiainaNum();
|
|
2802
|
+
obj.resetFromObject({
|
|
2803
|
+
array: [{
|
|
2804
|
+
arrow: 0,
|
|
2805
|
+
expans: 1,
|
|
2806
|
+
megota: 1,
|
|
2807
|
+
repeat: NaN
|
|
2808
|
+
}],
|
|
2809
|
+
small: false,
|
|
2810
|
+
layer: 0,
|
|
2811
|
+
sign: 0
|
|
2812
|
+
});
|
|
2813
|
+
if (Number.isNaN(x)) return obj;
|
|
2455
2814
|
if (x < 0) obj.sign = -1; // negative
|
|
2456
2815
|
else if (x == 0) {
|
|
2457
2816
|
obj.sign = 0;
|
|
@@ -2479,10 +2838,26 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2479
2838
|
}, {
|
|
2480
2839
|
key: "fromString",
|
|
2481
2840
|
value: function fromString(input) {
|
|
2841
|
+
if (PowiainaNum.usingBreakEternityLikeFromString && BE_REGEX.test(input)) {
|
|
2842
|
+
/*
|
|
2843
|
+
* 0i00000000a7 says that eee-3000 will wrongly parse to 1. So i added this
|
|
2844
|
+
*/
|
|
2845
|
+
var a = input.match(/(e+-)(\d+(.\d+)?)/);
|
|
2846
|
+
if (a) {
|
|
2847
|
+
var e_s = a[1].length;
|
|
2848
|
+
input = "e-" + "e".repeat(e_s - 1) + a[2];
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
return this.fromString_core(input);
|
|
2852
|
+
}
|
|
2853
|
+
}, {
|
|
2854
|
+
key: "fromString_core",
|
|
2855
|
+
value: function fromString_core(input) {
|
|
2482
2856
|
var _b, _c, _d, _e, _f, _g;
|
|
2483
|
-
var x = new PowiainaNum();
|
|
2857
|
+
var x = new PowiainaNum(NaN);
|
|
2484
2858
|
// Judge the string was a number
|
|
2485
2859
|
if (input.startsWith("PN")) input = input.substring(2);
|
|
2860
|
+
if (input == "NaN") return PowiainaNum.NaN.clone();
|
|
2486
2861
|
input = input.replace(/J\^(\d+)/g, "(10{!})^$1");
|
|
2487
2862
|
input = input.replace(/J/g, "10{!}");
|
|
2488
2863
|
input = input.replace(/K\^(\d+)/g, "(10{1,2})^$1");
|
|
@@ -2493,17 +2868,20 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2493
2868
|
input = input.replace(/M/g, "10{!,2}");
|
|
2494
2869
|
input = input.replace(/N\^(\d+)/g, "(10{1,!})^$1");
|
|
2495
2870
|
input = input.replace(/N/g, "10{1,!}");
|
|
2871
|
+
if (/^.*e-.*(e|\^).*/.test(input)) {
|
|
2872
|
+
input = "/10^" + input.substring(input.indexOf("e-"));
|
|
2873
|
+
}
|
|
2496
2874
|
if (!isNaN(Number(input))) {
|
|
2497
2875
|
var res = Number(input);
|
|
2498
|
-
var
|
|
2876
|
+
var a = false;
|
|
2499
2877
|
if (res == 0) {
|
|
2500
2878
|
if (/^((0)|(0*\.0+e\d+)|(0*\.0*))$/.test(input)) {
|
|
2501
|
-
|
|
2879
|
+
a = true;
|
|
2502
2880
|
}
|
|
2503
2881
|
} else {
|
|
2504
|
-
|
|
2882
|
+
a = true;
|
|
2505
2883
|
}
|
|
2506
|
-
if (!
|
|
2884
|
+
if (!a) {
|
|
2507
2885
|
var m = input.search(/e/);
|
|
2508
2886
|
var exponent = input.substring((m == -1 ? input.length : m) + 1);
|
|
2509
2887
|
var mantissa = input.substring(0, m == -1 ? undefined : m);
|
|
@@ -2513,11 +2891,11 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2513
2891
|
// Is regular number gte 1:
|
|
2514
2892
|
if (Number(mantissa) >= 1) {
|
|
2515
2893
|
// check The mantissa is very long?
|
|
2516
|
-
var log10mant = mantissa.length >= LONG_STRING_MIN_LENGTH ? log10LongString(mantissa) : Math.log10(Number(mantissa));
|
|
2517
|
-
var log10int = Math.floor(log10mant);
|
|
2518
|
-
var log10float = log10mant - log10int;
|
|
2894
|
+
var log10mant = mantissa.length >= LONG_STRING_MIN_LENGTH ? log10LongString(mantissa) : Math.log10(Number(mantissa)); // sample 10
|
|
2895
|
+
var log10int = Math.floor(log10mant); // sample 1
|
|
2896
|
+
var log10float = log10mant - log10int; // sample 0;
|
|
2519
2897
|
mantissaME[0] = Math.pow(10, log10float);
|
|
2520
|
-
mantissaME[1] +=
|
|
2898
|
+
mantissaME[1] += log10int;
|
|
2521
2899
|
} else {
|
|
2522
2900
|
// If not , count how many zeros until reached non-zero numbers
|
|
2523
2901
|
var zeros = countLeadingZerosAfterDecimal(mantissa);
|
|
@@ -2532,7 +2910,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2532
2910
|
// /((a*10^b)^-1) = /(a^-1*10^-b) = /(a^-1 * 10 * 10^(-b-1))
|
|
2533
2911
|
return PowiainaNum.pow(10, -mantissaME[1] - 1).mul(Math.pow(mantissaME[0], -1) * 10).rec();
|
|
2534
2912
|
}
|
|
2535
|
-
if (isFinite(res) &&
|
|
2913
|
+
if (isFinite(res) && a) {
|
|
2536
2914
|
x = PowiainaNum.fromNumber(Number(input));
|
|
2537
2915
|
return x;
|
|
2538
2916
|
}
|
|
@@ -2549,6 +2927,7 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2549
2927
|
return x;
|
|
2550
2928
|
}
|
|
2551
2929
|
input = replaceETo10(input);
|
|
2930
|
+
input = removeCommasOutsideBraces(input);
|
|
2552
2931
|
if (!isPowiainaNum.test(input)) {
|
|
2553
2932
|
throw powiainaNumError + "malformed input: " + input;
|
|
2554
2933
|
}
|
|
@@ -2561,28 +2940,31 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2561
2940
|
input = input.substring(numSigns);
|
|
2562
2941
|
}
|
|
2563
2942
|
if (input[0] == "/") {
|
|
2564
|
-
var
|
|
2565
|
-
var
|
|
2566
|
-
recipIt = ((_e = (_d =
|
|
2567
|
-
input = input.substring(
|
|
2943
|
+
var _numSigns = input.search(/[^\/]/);
|
|
2944
|
+
var _signs = input.substring(0, _numSigns);
|
|
2945
|
+
recipIt = ((_e = (_d = _signs.match(/\//g)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) % 2 == 1;
|
|
2946
|
+
input = input.substring(_numSigns);
|
|
2568
2947
|
}
|
|
2569
2948
|
if (input == "NaN") x.array = [newOperator(NaN)];else if (input == "Infinity") x.array = [newOperator(Infinity)];else {
|
|
2570
2949
|
x.sign = 1;
|
|
2571
2950
|
x.array = [newOperator(0)];
|
|
2572
|
-
var
|
|
2951
|
+
var _a3, b, c, d;
|
|
2573
2952
|
if (input[0] == "P") {
|
|
2574
2953
|
if (input[1] == "^") {
|
|
2575
|
-
|
|
2576
|
-
x.layer = Number(input.substring(2,
|
|
2577
|
-
input = input.substring(
|
|
2954
|
+
_a3 = input.substring(2).search(/[^0-9]/) + 2;
|
|
2955
|
+
x.layer = Number(input.substring(2, _a3));
|
|
2956
|
+
input = input.substring(_a3 + 1);
|
|
2578
2957
|
} else {
|
|
2579
|
-
|
|
2580
|
-
x.layer =
|
|
2581
|
-
input = input.substring(
|
|
2958
|
+
_a3 = input.search(/[^P]/);
|
|
2959
|
+
x.layer = _a3;
|
|
2960
|
+
input = input.substring(_a3);
|
|
2582
2961
|
}
|
|
2583
2962
|
}
|
|
2584
2963
|
while (input) {
|
|
2585
2964
|
if (/^(\(?10[\^\{])/.test(input)) {
|
|
2965
|
+
var arrows = void 0,
|
|
2966
|
+
expans = void 0,
|
|
2967
|
+
megota = void 0;
|
|
2586
2968
|
/*
|
|
2587
2969
|
10^ - 匹配
|
|
2588
2970
|
10{ - 匹配
|
|
@@ -2593,30 +2975,29 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2593
2975
|
*/
|
|
2594
2976
|
if (input[0] == "(") input = input.substring(1);
|
|
2595
2977
|
//cutted, 10^.... or 10{....
|
|
2596
|
-
var arrows, expans, megota;
|
|
2597
2978
|
if (input[2] == "^") {
|
|
2598
|
-
|
|
2979
|
+
_a3 = input.substring(2).search(/[^\^]/);
|
|
2599
2980
|
//cut input to ^^...^^, and search how numbers
|
|
2600
|
-
arrows =
|
|
2981
|
+
arrows = _a3;
|
|
2601
2982
|
// 10^^^
|
|
2602
|
-
b =
|
|
2983
|
+
b = _a3 + 2; // b points to after ^'s.
|
|
2603
2984
|
} else {
|
|
2604
2985
|
// 10{...}
|
|
2605
|
-
|
|
2986
|
+
_a3 = input.indexOf("}");
|
|
2606
2987
|
// select contents between {...}
|
|
2607
|
-
var tmp = input.substring(3,
|
|
2988
|
+
var tmp = input.substring(3, _a3).split(",");
|
|
2608
2989
|
arrows = Number(tmp[0] == "!" ? Infinity : tmp[0]);
|
|
2609
2990
|
expans = Number((_f = tmp[1] == "!" ? Infinity : tmp[1]) !== null && _f !== void 0 ? _f : 1);
|
|
2610
2991
|
megota = Number((_g = tmp[2]) !== null && _g !== void 0 ? _g : 1);
|
|
2611
|
-
b =
|
|
2992
|
+
b = _a3 + 1;
|
|
2612
2993
|
// b points to after }.
|
|
2613
2994
|
}
|
|
2614
2995
|
input = input.substring(b);
|
|
2615
2996
|
if (input[0] == ")") {
|
|
2616
2997
|
// )^....<Space>
|
|
2617
|
-
|
|
2618
|
-
c = Number(input.substring(2,
|
|
2619
|
-
input = input.substring(
|
|
2998
|
+
_a3 = input.indexOf(" ");
|
|
2999
|
+
c = Number(input.substring(2, _a3)); // Select contents between )^....<Space>
|
|
3000
|
+
input = input.substring(_a3 + 1); // c points to after <Space>
|
|
2620
3001
|
} else {
|
|
2621
3002
|
c = 1; // There is only spaces, count as <ONE>
|
|
2622
3003
|
}
|
|
@@ -2627,21 +3008,21 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2627
3008
|
x.array.splice(1, 0, newOperator(c, 1, expans, megota));
|
|
2628
3009
|
}
|
|
2629
3010
|
} else if (arrows == 2 && expans == 1 && megota == 1) {
|
|
2630
|
-
|
|
3011
|
+
_a3 = x.array.length >= 2 && x.array[1].arrow == 1 ? x.array[1].repeat : 0;
|
|
2631
3012
|
b = x.array[0].repeat;
|
|
2632
|
-
if (b >= 1e10) ++
|
|
2633
|
-
if (b >= 10) ++
|
|
2634
|
-
x.array[0].repeat =
|
|
3013
|
+
if (b >= 1e10) ++_a3;
|
|
3014
|
+
if (b >= 10) ++_a3;
|
|
3015
|
+
x.array[0].repeat = _a3;
|
|
2635
3016
|
if (x.array.length >= 2 && x.array[1].arrow == 1) x.array.splice(1, 1);
|
|
2636
3017
|
d = x.getOperatorIndex(2);
|
|
2637
3018
|
if (Number.isInteger(d)) x.array[d].repeat += c;else x.array.splice(Math.ceil(d), 0, newOperator(c, 2, expans, megota));
|
|
2638
3019
|
} else if (isFinite(arrows)) {
|
|
2639
|
-
|
|
3020
|
+
_a3 = x.getOperator(arrows - 1);
|
|
2640
3021
|
b = x.getOperator(arrows - 2);
|
|
2641
|
-
if (b >= 10) ++
|
|
3022
|
+
if (b >= 10) ++_a3;
|
|
2642
3023
|
d = x.getOperatorIndex(arrows);
|
|
2643
3024
|
x.array.splice(1, Math.ceil(d) - 1);
|
|
2644
|
-
x.array[0].repeat =
|
|
3025
|
+
x.array[0].repeat = _a3;
|
|
2645
3026
|
if (Number.isInteger(d)) x.array[1].repeat += c;else x.array.splice(1, 0, newOperator(c, arrows, expans, megota));
|
|
2646
3027
|
} else {
|
|
2647
3028
|
x.array.splice(1, 0, newOperator(c, arrows, expans, megota));
|
|
@@ -2650,10 +3031,10 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2650
3031
|
break;
|
|
2651
3032
|
}
|
|
2652
3033
|
}
|
|
2653
|
-
|
|
3034
|
+
_a3 = input.split(/[Ee]/);
|
|
2654
3035
|
b = [x.array[0].repeat, 0];
|
|
2655
3036
|
c = 1;
|
|
2656
|
-
for (var
|
|
3037
|
+
for (var i = _a3.length - 1; i >= 0; --i) {
|
|
2657
3038
|
//The things that are already there
|
|
2658
3039
|
if (b[0] < MSI_LOG10 && b[1] === 0) {
|
|
2659
3040
|
b[0] = Math.pow(10, c * b[0]);
|
|
@@ -2670,12 +3051,12 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2670
3051
|
b[1]++;
|
|
2671
3052
|
}
|
|
2672
3053
|
//Multiplying coefficient
|
|
2673
|
-
var decimalPointPos =
|
|
2674
|
-
var intPartLen = decimalPointPos == -1 ?
|
|
3054
|
+
var decimalPointPos = _a3[i].indexOf(".");
|
|
3055
|
+
var intPartLen = decimalPointPos == -1 ? _a3[i].length : decimalPointPos;
|
|
2675
3056
|
if (b[1] === 0) {
|
|
2676
|
-
if (intPartLen >= LONG_STRING_MIN_LENGTH) b[0] = Math.log10(b[0]) + log10LongString(
|
|
3057
|
+
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]);
|
|
2677
3058
|
} else {
|
|
2678
|
-
d = intPartLen >= LONG_STRING_MIN_LENGTH ? log10LongString(
|
|
3059
|
+
d = intPartLen >= LONG_STRING_MIN_LENGTH ? log10LongString(_a3[i].substring(0, intPartLen)) : _a3[i] ? Math.log10(Number(_a3[i])) : 0;
|
|
2679
3060
|
if (b[1] == 1) {
|
|
2680
3061
|
b[0] += d;
|
|
2681
3062
|
} else if (b[1] == 2 && b[0] < MSI_LOG10 + Math.log10(d)) {
|
|
@@ -2706,6 +3087,17 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2706
3087
|
key: "fromObject",
|
|
2707
3088
|
value: function fromObject(powlikeObject) {
|
|
2708
3089
|
var obj = new PowiainaNum();
|
|
3090
|
+
obj.resetFromObject({
|
|
3091
|
+
array: [{
|
|
3092
|
+
arrow: 0,
|
|
3093
|
+
expans: 1,
|
|
3094
|
+
megota: 1,
|
|
3095
|
+
repeat: NaN
|
|
3096
|
+
}],
|
|
3097
|
+
small: false,
|
|
3098
|
+
layer: 0,
|
|
3099
|
+
sign: 0
|
|
3100
|
+
});
|
|
2709
3101
|
obj.array = [];
|
|
2710
3102
|
if (isExpantaNumArray(powlikeObject)) {
|
|
2711
3103
|
for (var i = 0; i < powlikeObject.length; i++) {
|
|
@@ -2723,8 +3115,8 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2723
3115
|
} else if (isPowiainaNum01XArray(powlikeObject)) {
|
|
2724
3116
|
var arrayobj = powlikeObject;
|
|
2725
3117
|
obj.array[0] = newOperator(arrayobj[0]);
|
|
2726
|
-
for (var
|
|
2727
|
-
var b = arrayobj[
|
|
3118
|
+
for (var _i4 = 1; _i4 < arrayobj.length; _i4++) {
|
|
3119
|
+
var b = arrayobj[_i4];
|
|
2728
3120
|
obj.array[1] = newOperator(b[1], replaceXToInfinity(b[0]), replaceXToInfinity(b[2]), b[3]);
|
|
2729
3121
|
}
|
|
2730
3122
|
obj.small = false;
|
|
@@ -2732,21 +3124,21 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
2732
3124
|
obj.layer = 0;
|
|
2733
3125
|
return obj;
|
|
2734
3126
|
} else {
|
|
2735
|
-
|
|
2736
|
-
obj.array[_i4] = {
|
|
2737
|
-
arrow: powlikeObject.array[_i4].arrow,
|
|
2738
|
-
expans: powlikeObject.array[_i4].expans,
|
|
2739
|
-
megota: powlikeObject.array[_i4].megota,
|
|
2740
|
-
repeat: powlikeObject.array[_i4].repeat,
|
|
2741
|
-
valuereplaced: powlikeObject.array[_i4].valuereplaced
|
|
2742
|
-
};
|
|
2743
|
-
}
|
|
2744
|
-
obj.small = powlikeObject.small;
|
|
2745
|
-
obj.sign = powlikeObject.sign;
|
|
2746
|
-
obj.layer = powlikeObject.layer;
|
|
3127
|
+
obj.resetFromObject(powlikeObject);
|
|
2747
3128
|
return obj;
|
|
2748
3129
|
}
|
|
2749
3130
|
}
|
|
3131
|
+
}, {
|
|
3132
|
+
key: "grahalFunction",
|
|
3133
|
+
value: function grahalFunction(layers2) {
|
|
3134
|
+
var layers = new PowiainaNum(layers2);
|
|
3135
|
+
if (!layers.isInt() || layers.lt(0) || layers.isNaN()) return PowiainaNum.NaN.clone();
|
|
3136
|
+
if (layers.eq(1)) return new PowiainaNum("10^^^(10^)^7625597484984 3638334640023.7783");else if (layers.lte(MSI)) {
|
|
3137
|
+
return new PowiainaNum("(10{!})^".concat(layers.toNumber(), " 10^^^(10^)^7625597484984 3638334640023.7783"));
|
|
3138
|
+
} else {
|
|
3139
|
+
return PowiainaNum.BEAF(3, layers, 1, 2);
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
2750
3142
|
}]);
|
|
2751
3143
|
}();
|
|
2752
3144
|
_a = Symbol.toStringTag;
|
|
@@ -2963,5 +3355,19 @@ PowiainaNum.maxOps = 100;
|
|
|
2963
3355
|
PowiainaNum.POW_2_44_MOD_PI = 1.701173079953;
|
|
2964
3356
|
//#endregion
|
|
2965
3357
|
PowiainaNum.arrowFuncMap = new Map();
|
|
3358
|
+
//#region configurations
|
|
3359
|
+
/**
|
|
3360
|
+
* If you set this config to true,
|
|
3361
|
+
* 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.
|
|
3362
|
+
*/
|
|
3363
|
+
PowiainaNum.usingBreakEternityLikeFromString = true;
|
|
3364
|
+
/**
|
|
3365
|
+
* If you set this config to true, the `constructor` method will return Zero instead of NaN when call new PowiainaNum() with no arguments.
|
|
3366
|
+
*/
|
|
3367
|
+
PowiainaNum.blankArgumentConstructorReturnZero = false;
|
|
3368
|
+
/**
|
|
3369
|
+
* If you set this config to true, when calucation returns NaN, the program will throw error.
|
|
3370
|
+
*/
|
|
3371
|
+
PowiainaNum.throwErrorOnResultNaN = false;
|
|
2966
3372
|
|
|
2967
3373
|
export { arraySortFunction, PowiainaNum as default, mergeSameArrays };
|