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.js
CHANGED
|
@@ -68,6 +68,8 @@
|
|
|
68
68
|
|
|
69
69
|
/* Author: VeryrrDefine 0.2.0-beta.1.1*/
|
|
70
70
|
var _a;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region constants
|
|
71
73
|
var powiainaNumError = "[PowiainaNum 0.2 error]";
|
|
72
74
|
var MSI = 9007199254740991;
|
|
73
75
|
var MSI_LOG10 = 15.954589770191003;
|
|
@@ -75,6 +77,8 @@
|
|
|
75
77
|
var LONG_STRING_MIN_LENGTH = 17;
|
|
76
78
|
var EXP_E_REC = 1.444667861009766;
|
|
77
79
|
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+))$/;
|
|
80
|
+
var BE_REGEX = /^((\d+(\.\d*)?|\d*\.\d+)?([EeFf]([-\+]?)))*(0|\d+(\.\d*)?|\d*\.\d+)$/;
|
|
81
|
+
//#endregion
|
|
78
82
|
//#region some useful functions
|
|
79
83
|
function newOperator(r) {
|
|
80
84
|
var a = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
@@ -88,6 +92,29 @@
|
|
|
88
92
|
valuereplaced: a == Infinity ? 0 : e == Infinity ? 1 : -1
|
|
89
93
|
};
|
|
90
94
|
}
|
|
95
|
+
function removeCommasOutsideBraces(input) {
|
|
96
|
+
var result = "";
|
|
97
|
+
var inBraces = false;
|
|
98
|
+
for (var i = 0; i < input.length; i++) {
|
|
99
|
+
var _char = input[i];
|
|
100
|
+
if (_char === "{") {
|
|
101
|
+
inBraces = true;
|
|
102
|
+
result += _char;
|
|
103
|
+
} else if (_char === "}") {
|
|
104
|
+
inBraces = false;
|
|
105
|
+
result += _char;
|
|
106
|
+
} else if (_char === ",") {
|
|
107
|
+
// 只有在花括号内部才保留逗号
|
|
108
|
+
if (inBraces) {
|
|
109
|
+
result += _char;
|
|
110
|
+
}
|
|
111
|
+
// 如果在花括号外部,就不添加到结果中(相当于删除)
|
|
112
|
+
} else {
|
|
113
|
+
result += _char;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
91
118
|
// parse 0.1.x PowiainaNum.js string
|
|
92
119
|
function parseLegacyPowiainaNumString(str) {
|
|
93
120
|
var pattern = /l(\d+)\s+s(\d+)\s+a(\[.*\])/;
|
|
@@ -120,7 +147,7 @@
|
|
|
120
147
|
function replaceETo10(str) {
|
|
121
148
|
// 使用正则表达式匹配 (e^数字) 的模式
|
|
122
149
|
// 正则解释:\(e\^(\d+)\) 匹配 (e^数字),其中 \d+ 匹配一个或多个数字
|
|
123
|
-
return str.replace(/\(e\^(\d+)\)/g, "(10^)^$1 ").replace(/(\d+)
|
|
150
|
+
return str.replace(/\(e\^(\d+)\)/g, "(10^)^$1 ").replace(/(\d+)[Pp][Tt]/g, "(10^)^$1 ");
|
|
124
151
|
}
|
|
125
152
|
/**
|
|
126
153
|
* 把一个字符串很长的数进行以10为底的对数
|
|
@@ -174,8 +201,10 @@
|
|
|
174
201
|
// The evaluation can become inaccurate very close to the branch point
|
|
175
202
|
// Evaluates W(x, 0) if principal is true, W(x, -1) if principal is false
|
|
176
203
|
function f_lambertw(z) {
|
|
177
|
-
var
|
|
178
|
-
var
|
|
204
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1e-10;
|
|
205
|
+
var pr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
206
|
+
var tol = t;
|
|
207
|
+
var principal = pr;
|
|
179
208
|
var w;
|
|
180
209
|
var wn;
|
|
181
210
|
if (!Number.isFinite(z)) {
|
|
@@ -338,16 +367,27 @@
|
|
|
338
367
|
this.small = false;
|
|
339
368
|
this.sign = 0;
|
|
340
369
|
this.layer = 0;
|
|
341
|
-
if (
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
370
|
+
if (PowiainaNum.blankArgumentConstructorReturnZero) {
|
|
371
|
+
this.resetFromObject(PowiainaNum.ZERO);
|
|
372
|
+
}
|
|
373
|
+
try {
|
|
374
|
+
if (typeof arg1 == "undefined") {} else if (typeof arg1 == "number") {
|
|
375
|
+
var obj = PowiainaNum.fromNumber(arg1);
|
|
376
|
+
this.resetFromObject(obj);
|
|
377
|
+
} else if (_typeof(arg1) == "object") {
|
|
378
|
+
var _obj = PowiainaNum.fromObject(arg1);
|
|
379
|
+
this.resetFromObject(_obj);
|
|
380
|
+
} else if (typeof arg1 == "string") {
|
|
381
|
+
var _obj2 = PowiainaNum.fromString(arg1);
|
|
382
|
+
this.resetFromObject(_obj2);
|
|
383
|
+
} else {
|
|
384
|
+
var isn = arg1;
|
|
385
|
+
}
|
|
386
|
+
} catch (e) {
|
|
387
|
+
console.error("Malformed input");
|
|
388
|
+
console.error(e);
|
|
389
|
+
if (PowiainaNum.throwErrorOnResultNaN && PowiainaNum.isNaN(this)) throw new Error("NaN");
|
|
390
|
+
}
|
|
351
391
|
}
|
|
352
392
|
//#region 4 Basic calculates.
|
|
353
393
|
/**
|
|
@@ -358,10 +398,13 @@
|
|
|
358
398
|
key: "add",
|
|
359
399
|
value: function add(other) {
|
|
360
400
|
var _b, _c, _d, _e;
|
|
361
|
-
var x = this.clone();
|
|
401
|
+
var x = this.clone().normalize();
|
|
362
402
|
var y = new PowiainaNum(other);
|
|
363
403
|
// inf + -inf = nan
|
|
364
|
-
if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY))
|
|
404
|
+
if (x.eq(PowiainaNum.POSITIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY) || x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.POSITIVE_INFINITY)) {
|
|
405
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
406
|
+
return PowiainaNum.NaN.clone();
|
|
407
|
+
}
|
|
365
408
|
// inf & nan check
|
|
366
409
|
if (!x.isFinite()) return x.clone();
|
|
367
410
|
if (!y.isFinite()) return y.clone();
|
|
@@ -401,40 +444,56 @@
|
|
|
401
444
|
if (isFinite(temp) && temp !== 0) {
|
|
402
445
|
return PowiainaNum.fromNumber(temp);
|
|
403
446
|
}
|
|
404
|
-
var
|
|
447
|
+
var signMult = 1;
|
|
448
|
+
/**Calculate numbers [1, 9e15] (useless) */
|
|
405
449
|
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) {
|
|
406
450
|
return new PowiainaNum((a.array[0].repeat + b.array[0].repeat) * a.sign);
|
|
407
451
|
}
|
|
452
|
+
// Calculate a & b's 10-logarithm
|
|
408
453
|
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));
|
|
409
454
|
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));
|
|
410
455
|
if (alog10 - blog10 > MSI_LOG10) return a;
|
|
456
|
+
/**
|
|
457
|
+
* Offset, a number can make 10^ a+off calculatable not very small or big
|
|
458
|
+
*/
|
|
411
459
|
var offset = -Math.floor(alog10); //a number can make a+off in [0,1)
|
|
412
|
-
var
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
if (
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
if (
|
|
425
|
-
|
|
460
|
+
var resultLogarithm = 0;
|
|
461
|
+
/** 10^(a+off) + 10^(b+off). */
|
|
462
|
+
var offsetedResult = a.sign * Math.pow(10, alog10 + offset) + b.sign * Math.pow(10, blog10 + offset);
|
|
463
|
+
if (offsetedResult > 0) resultLogarithm = Math.log10(offsetedResult) - offset;
|
|
464
|
+
if (offsetedResult < 0) {
|
|
465
|
+
resultLogarithm = Math.log10(-offsetedResult) - offset;
|
|
466
|
+
signMult *= -1;
|
|
467
|
+
}
|
|
468
|
+
if (offsetedResult == 0) return PowiainaNum.ZERO.clone();
|
|
469
|
+
var resultPN = PowiainaNum.NaN.clone();
|
|
470
|
+
resultPN.sign = 1;
|
|
471
|
+
/** abs(resultLogarithm) > 15.9, use 10^x form. */
|
|
472
|
+
if (resultLogarithm > MSI_LOG10 || resultLogarithm < -MSI_LOG10) {
|
|
473
|
+
resultPN.array = [newOperator(resultLogarithm, 0), newOperator(1, 1)];
|
|
474
|
+
/**otherwise, use 10** abs(resultLogarithm) */
|
|
426
475
|
} else {
|
|
427
|
-
|
|
476
|
+
resultPN.array = [newOperator(Math.pow(10, Math.abs(resultLogarithm)), 0)];
|
|
428
477
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
return
|
|
478
|
+
resultPN.small = resultLogarithm < 0 ? true : false;
|
|
479
|
+
resultPN.sign *= signMult;
|
|
480
|
+
return resultPN;
|
|
481
|
+
}
|
|
482
|
+
}, {
|
|
483
|
+
key: "plus",
|
|
484
|
+
value: function plus(other) {
|
|
485
|
+
return this.add(other);
|
|
432
486
|
}
|
|
433
487
|
}, {
|
|
434
488
|
key: "sub",
|
|
435
489
|
value: function sub(a) {
|
|
436
490
|
return this.add(new PowiainaNum(a).neg());
|
|
437
491
|
}
|
|
492
|
+
}, {
|
|
493
|
+
key: "minus",
|
|
494
|
+
value: function minus(other) {
|
|
495
|
+
return this.sub(other);
|
|
496
|
+
}
|
|
438
497
|
}, {
|
|
439
498
|
key: "mul",
|
|
440
499
|
value: function mul(other) {
|
|
@@ -442,7 +501,10 @@
|
|
|
442
501
|
var y = new PowiainaNum(other);
|
|
443
502
|
// inf * -inf = -inf
|
|
444
503
|
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();
|
|
445
|
-
if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero())
|
|
504
|
+
if (x.isInfiNaN() && y.isZero() || y.isInfiNaN() && x.isZero()) {
|
|
505
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
506
|
+
return PowiainaNum.NaN.clone();
|
|
507
|
+
}
|
|
446
508
|
if (x.eq(PowiainaNum.NEGATIVE_INFINITY) && y.eq(PowiainaNum.NEGATIVE_INFINITY)) return PowiainaNum.POSITIVE_INFINITY.clone();
|
|
447
509
|
// inf & nan check
|
|
448
510
|
if (!x.isFinite()) return x.clone();
|
|
@@ -468,12 +530,22 @@
|
|
|
468
530
|
r.sign = x.sign * y.sign;
|
|
469
531
|
return r;
|
|
470
532
|
}
|
|
533
|
+
}, {
|
|
534
|
+
key: "times",
|
|
535
|
+
value: function times(other) {
|
|
536
|
+
return this.mul(other);
|
|
537
|
+
}
|
|
471
538
|
}, {
|
|
472
539
|
key: "div",
|
|
473
540
|
value: function div(other) {
|
|
474
541
|
var x = new PowiainaNum(other).rec();
|
|
475
542
|
return this.mul(x);
|
|
476
543
|
}
|
|
544
|
+
}, {
|
|
545
|
+
key: "divide",
|
|
546
|
+
value: function divide(other) {
|
|
547
|
+
return this.div(other);
|
|
548
|
+
}
|
|
477
549
|
}, {
|
|
478
550
|
key: "mod",
|
|
479
551
|
value: function mod(x) {
|
|
@@ -481,34 +553,45 @@
|
|
|
481
553
|
var division = this.div(other);
|
|
482
554
|
return division.sub(division.floor()).mul(other);
|
|
483
555
|
}
|
|
556
|
+
}, {
|
|
557
|
+
key: "modulus",
|
|
558
|
+
value: function modulus(x) {
|
|
559
|
+
return this.mod(x);
|
|
560
|
+
}
|
|
561
|
+
}, {
|
|
562
|
+
key: "pow10",
|
|
563
|
+
value:
|
|
484
564
|
//#endregion
|
|
485
565
|
//#region power
|
|
486
566
|
/**
|
|
487
567
|
* @returns 10 to the power of `this`
|
|
488
568
|
*/
|
|
489
|
-
|
|
490
|
-
key: "pow10",
|
|
491
|
-
value: function pow10() {
|
|
569
|
+
function pow10() {
|
|
492
570
|
var _b, _c;
|
|
493
|
-
var
|
|
571
|
+
var thisObject = this.clone();
|
|
494
572
|
// inf & nan check
|
|
495
573
|
if (!this.isFinite()) return this.clone();
|
|
496
|
-
|
|
574
|
+
/** when 10^(t), t<0, use 10^(-t) reciprocate. */
|
|
575
|
+
if (thisObject.isneg()) {
|
|
497
576
|
// 10^(-x) = 1/(10^x)
|
|
498
|
-
|
|
499
|
-
return
|
|
577
|
+
thisObject.sign *= -1;
|
|
578
|
+
return thisObject.pow10().rec();
|
|
500
579
|
}
|
|
501
|
-
if
|
|
502
|
-
|
|
580
|
+
/**if t lessthan log10 2^1024, use fromNumber. */
|
|
581
|
+
if (thisObject.lte(308.25471555991675)) {
|
|
582
|
+
return PowiainaNum.fromNumber(Math.pow(10, thisObject.toNumber()));
|
|
503
583
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
584
|
+
/**calculate directly */
|
|
585
|
+
if (thisObject.small) {
|
|
586
|
+
if (thisObject.lt(PowiainaNum.MSI_REC)) return PowiainaNum.ONE;
|
|
587
|
+
return new PowiainaNum(Math.pow(10, Math.pow(thisObject.array[0].repeat, -1)));
|
|
507
588
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
589
|
+
/** indistinguishable above 10^^9e15 */
|
|
590
|
+
if (thisObject.gt(PowiainaNum.TETRATED_MSI)) return thisObject;
|
|
591
|
+
/**otherwise add 10^ directly */
|
|
592
|
+
thisObject.setOperator(((_c = (_b = thisObject.array[1]) === null || _b === void 0 ? void 0 : _b.repeat) !== null && _c !== void 0 ? _c : 0) + 1, 1);
|
|
593
|
+
thisObject.normalize();
|
|
594
|
+
return thisObject;
|
|
512
595
|
}
|
|
513
596
|
}, {
|
|
514
597
|
key: "pow",
|
|
@@ -518,8 +601,17 @@
|
|
|
518
601
|
if (!other.isFinite()) return other.clone();
|
|
519
602
|
if (!this.isFinite()) return this.clone();
|
|
520
603
|
if (this.eq(10)) return other.pow10();
|
|
604
|
+
if (other.isneg()) return this.pow(other.neg()).rec();
|
|
521
605
|
if (this.isneg()) {
|
|
522
|
-
if (!other.isInt())
|
|
606
|
+
if (!other.isInt()) {
|
|
607
|
+
if (other.small) {
|
|
608
|
+
if (other.rec().div(2).eq(1)) {
|
|
609
|
+
return this.neg().pow(other).neg();
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
613
|
+
return PowiainaNum.NaN.clone();
|
|
614
|
+
}
|
|
523
615
|
var r = this.abs().pow(other);
|
|
524
616
|
r.sign = function () {
|
|
525
617
|
var a = other.mod(2).round();
|
|
@@ -547,6 +639,7 @@
|
|
|
547
639
|
} else if (other.rec().mod(2).eq(1)) {
|
|
548
640
|
return this.neg().log10().mul(other).pow10().neg();
|
|
549
641
|
}
|
|
642
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
550
643
|
return PowiainaNum.NaN.clone();
|
|
551
644
|
}
|
|
552
645
|
}, {
|
|
@@ -574,7 +667,10 @@
|
|
|
574
667
|
}, {
|
|
575
668
|
key: "log10",
|
|
576
669
|
value: function log10() {
|
|
577
|
-
if (this.isneg())
|
|
670
|
+
if (this.isneg()) {
|
|
671
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
672
|
+
return PowiainaNum.NaN.clone();
|
|
673
|
+
}
|
|
578
674
|
if (this.isZero()) return PowiainaNum.NEGATIVE_INFINITY.clone();
|
|
579
675
|
if (this.small) {
|
|
580
676
|
var _x = this.clone();
|
|
@@ -596,6 +692,16 @@
|
|
|
596
692
|
var other = new PowiainaNum(base);
|
|
597
693
|
return this.log10().div(other.log10());
|
|
598
694
|
}
|
|
695
|
+
}, {
|
|
696
|
+
key: "log2",
|
|
697
|
+
value: function log2() {
|
|
698
|
+
return this.log(2);
|
|
699
|
+
}
|
|
700
|
+
}, {
|
|
701
|
+
key: "logBase",
|
|
702
|
+
value: function logBase(a) {
|
|
703
|
+
return this.log(a);
|
|
704
|
+
}
|
|
599
705
|
}, {
|
|
600
706
|
key: "ln",
|
|
601
707
|
value: function ln() {
|
|
@@ -703,8 +809,10 @@
|
|
|
703
809
|
//Code from break_eternity.js
|
|
704
810
|
//Some special values, for testing: https://en.wikipedia.org/wiki/Lambert_W_function#Special_values
|
|
705
811
|
function lambertw() {
|
|
706
|
-
var
|
|
812
|
+
var princ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
813
|
+
var principal = princ;
|
|
707
814
|
if (this.lt(-0.3678794411710499)) {
|
|
815
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
708
816
|
return PowiainaNum.NaN.clone(); //complex
|
|
709
817
|
} else if (principal) {
|
|
710
818
|
if (this.abs().lt("1e-300")) return new PowiainaNum(this);else if (this.small) {
|
|
@@ -718,12 +826,13 @@
|
|
|
718
826
|
return this.log();
|
|
719
827
|
}
|
|
720
828
|
} else {
|
|
721
|
-
if (this.sign === 1) {
|
|
829
|
+
if (this.sign === -1) {
|
|
830
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
722
831
|
return PowiainaNum.NaN.clone(); //complex
|
|
723
832
|
}
|
|
724
|
-
if (this.
|
|
833
|
+
if (this.lt(9e15)) {
|
|
725
834
|
return PowiainaNum.fromNumber(f_lambertw(this.sign * this.array[0].repeat, 1e-10, false));
|
|
726
|
-
} else if (this.
|
|
835
|
+
} else if (this.lt(PowiainaNum.E_MSI)) {
|
|
727
836
|
return d_lambertw(this, 1e-10, false);
|
|
728
837
|
} else {
|
|
729
838
|
return this.neg().rec().lambertw().neg();
|
|
@@ -742,23 +851,37 @@
|
|
|
742
851
|
var t = this.clone();
|
|
743
852
|
var other = new PowiainaNum(other2);
|
|
744
853
|
var payl = new PowiainaNum(payload);
|
|
745
|
-
if (t.isNaN() || other.isNaN() || payl.isNaN())
|
|
854
|
+
if (t.isNaN() || other.isNaN() || payl.isNaN()) {
|
|
855
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
856
|
+
return PowiainaNum.NaN.clone();
|
|
857
|
+
}
|
|
746
858
|
if (t.eq(1)) return PowiainaNum.ONE.clone();
|
|
747
|
-
if (payl.neq(PowiainaNum.ONE)
|
|
859
|
+
if (payl.neq(PowiainaNum.ONE) && t.gte(EXP_E_REC)) {
|
|
860
|
+
other = other.add(payl.slog(t));
|
|
861
|
+
}
|
|
748
862
|
var negln;
|
|
749
863
|
if (other.isInfi() && other.sign > 0) {
|
|
750
864
|
if (t.gte(EXP_E_REC)) return PowiainaNum.POSITIVE_INFINITY.clone();
|
|
751
865
|
negln = this.log().neg();
|
|
752
866
|
return negln.lambertw().div(negln);
|
|
753
867
|
}
|
|
754
|
-
if (other.lte(-2))
|
|
868
|
+
if (other.lte(-2)) {
|
|
869
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
870
|
+
return PowiainaNum.NaN.clone();
|
|
871
|
+
}
|
|
755
872
|
if (t.isZero()) {
|
|
756
|
-
if (other.isZero())
|
|
873
|
+
if (other.isZero()) {
|
|
874
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
875
|
+
return PowiainaNum.NaN.clone();
|
|
876
|
+
}
|
|
757
877
|
if (other.gte(MSI / 2) || other.toNumber() % 2 == 0) return PowiainaNum.ZERO.clone();
|
|
758
878
|
return PowiainaNum.ONE.clone();
|
|
759
879
|
}
|
|
760
880
|
if (t.eq(PowiainaNum.ONE)) {
|
|
761
|
-
if (other.eq(PowiainaNum.ONE.neg()))
|
|
881
|
+
if (other.eq(PowiainaNum.ONE.neg())) {
|
|
882
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
883
|
+
return PowiainaNum.NaN.clone();
|
|
884
|
+
}
|
|
762
885
|
return PowiainaNum.ONE.clone();
|
|
763
886
|
}
|
|
764
887
|
if (other.eq(PowiainaNum.ONE.neg())) return PowiainaNum.ZERO.clone();
|
|
@@ -832,7 +955,10 @@
|
|
|
832
955
|
if (b.lt(EXP_E_REC)) {
|
|
833
956
|
var a = b.tetrate(Infinity);
|
|
834
957
|
if (x.eq(a)) return PowiainaNum.POSITIVE_INFINITY.clone();
|
|
835
|
-
if (x.gt(a))
|
|
958
|
+
if (x.gt(a)) {
|
|
959
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
960
|
+
return PowiainaNum.NaN.clone();
|
|
961
|
+
}
|
|
836
962
|
}
|
|
837
963
|
if (x.max(b).gt(PowiainaNum.PENTATED_MSI)) {
|
|
838
964
|
if (x.gt(b)) return x;
|
|
@@ -876,13 +1002,17 @@
|
|
|
876
1002
|
}
|
|
877
1003
|
}
|
|
878
1004
|
if (x.gt(10)) return new PowiainaNum(r);
|
|
1005
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
879
1006
|
return PowiainaNum.NaN.clone();
|
|
880
1007
|
}
|
|
881
1008
|
}, {
|
|
882
1009
|
key: "ssqrt",
|
|
883
1010
|
value: function ssqrt() {
|
|
884
1011
|
var x = this.clone();
|
|
885
|
-
if (x.lt(1 / EXP_E_REC))
|
|
1012
|
+
if (x.lt(1 / EXP_E_REC)) {
|
|
1013
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1014
|
+
return PowiainaNum.NaN.clone();
|
|
1015
|
+
}
|
|
886
1016
|
if (!x.isFinite()) return x;
|
|
887
1017
|
if (x.gt(PowiainaNum.TETRATED_MSI)) return x;
|
|
888
1018
|
if (x.gt(PowiainaNum.EE_MSI)) {
|
|
@@ -933,6 +1063,7 @@
|
|
|
933
1063
|
if (!arrows.isInt() || arrows.lt(PowiainaNum.ZERO)) {
|
|
934
1064
|
console.warn("The arrow is <0 or not a integer, the returned function will return NaN.");
|
|
935
1065
|
return function () {
|
|
1066
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
936
1067
|
return PowiainaNum.NaN.clone();
|
|
937
1068
|
};
|
|
938
1069
|
}
|
|
@@ -958,6 +1089,7 @@
|
|
|
958
1089
|
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
|
|
959
1090
|
if (t.eq(PowiainaNum.ZERO)) {
|
|
960
1091
|
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
|
|
1092
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
961
1093
|
return PowiainaNum.NaN.clone();
|
|
962
1094
|
}
|
|
963
1095
|
if (payload.neq(PowiainaNum.ONE)) other = other.add(payload.anyarrow_log(arrows)(t));
|
|
@@ -1037,6 +1169,7 @@
|
|
|
1037
1169
|
throw new Error(powiainaNumError + "Not implemented");
|
|
1038
1170
|
}
|
|
1039
1171
|
if (!arrow.isInt() || arrow.lt(0)) return function () {
|
|
1172
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1040
1173
|
return PowiainaNum.NaN.clone();
|
|
1041
1174
|
};
|
|
1042
1175
|
if (arrow.eq(0)) return function (base) {
|
|
@@ -1070,13 +1203,16 @@
|
|
|
1070
1203
|
return x.sub(x.getOperator(arrowsNum - 1));
|
|
1071
1204
|
}
|
|
1072
1205
|
}
|
|
1073
|
-
if (x.lt(PowiainaNum.ZERO.clone()))
|
|
1206
|
+
if (x.lt(PowiainaNum.ZERO.clone())) {
|
|
1207
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1208
|
+
return PowiainaNum.NaN.clone();
|
|
1209
|
+
}
|
|
1074
1210
|
// base^base^... = x? (? bases)
|
|
1075
1211
|
var r = 0;
|
|
1076
1212
|
// 计算x与base的差距
|
|
1077
|
-
var
|
|
1078
|
-
if (
|
|
1079
|
-
var l =
|
|
1213
|
+
var distanceLayerOf = x.getOperator(arrowsNum) - b.getOperator(arrowsNum);
|
|
1214
|
+
if (distanceLayerOf > 3) {
|
|
1215
|
+
var l = distanceLayerOf - 3;
|
|
1080
1216
|
r += l;
|
|
1081
1217
|
x.setOperator(x.getOperator(arrowsNum) - l, arrowsNum);
|
|
1082
1218
|
}
|
|
@@ -1094,6 +1230,7 @@
|
|
|
1094
1230
|
}
|
|
1095
1231
|
}
|
|
1096
1232
|
if (x.gt(10)) return new PowiainaNum(r);
|
|
1233
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1097
1234
|
return PowiainaNum.NaN.clone();
|
|
1098
1235
|
};
|
|
1099
1236
|
}
|
|
@@ -1118,18 +1255,18 @@
|
|
|
1118
1255
|
}
|
|
1119
1256
|
}, {
|
|
1120
1257
|
key: "pentate",
|
|
1121
|
-
value: function pentate(other) {
|
|
1122
|
-
return this.arrow(3)(other);
|
|
1258
|
+
value: function pentate(other, payload) {
|
|
1259
|
+
return this.arrow(3)(other, payload);
|
|
1123
1260
|
}
|
|
1124
1261
|
}, {
|
|
1125
1262
|
key: "hexate",
|
|
1126
|
-
value: function hexate(other) {
|
|
1127
|
-
return this.arrow(4)(other);
|
|
1263
|
+
value: function hexate(other, payload) {
|
|
1264
|
+
return this.arrow(4)(other, payload);
|
|
1128
1265
|
}
|
|
1129
1266
|
}, {
|
|
1130
1267
|
key: "pent",
|
|
1131
|
-
value: function pent(other) {
|
|
1132
|
-
return this.arrow(3)(other);
|
|
1268
|
+
value: function pent(other, payload) {
|
|
1269
|
+
return this.arrow(3)(other, payload);
|
|
1133
1270
|
}
|
|
1134
1271
|
}, {
|
|
1135
1272
|
key: "penta_log",
|
|
@@ -1137,6 +1274,9 @@
|
|
|
1137
1274
|
var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10;
|
|
1138
1275
|
return this.anyarrow_log(3)(base);
|
|
1139
1276
|
}
|
|
1277
|
+
}, {
|
|
1278
|
+
key: "expansion",
|
|
1279
|
+
value:
|
|
1140
1280
|
/**
|
|
1141
1281
|
* Expansion, which is `this`{{1}}`other2`.
|
|
1142
1282
|
*
|
|
@@ -1144,15 +1284,16 @@
|
|
|
1144
1284
|
*
|
|
1145
1285
|
* @url https://googology.fandom.com/wiki/Expansion
|
|
1146
1286
|
*/
|
|
1147
|
-
|
|
1148
|
-
key: "expansion",
|
|
1149
|
-
value: function expansion(other2) {
|
|
1287
|
+
function expansion(other2) {
|
|
1150
1288
|
var other = new PowiainaNum(other2);
|
|
1151
1289
|
var t = this.clone();
|
|
1152
1290
|
if (other.lt(PowiainaNum.ZERO) || !other.isInt()) return PowiainaNum.NaN.clone();
|
|
1153
1291
|
if (other.eq(PowiainaNum.ONE)) return this.clone();
|
|
1154
1292
|
if (this.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
|
|
1155
|
-
if (!this.isInt())
|
|
1293
|
+
if (!this.isInt()) {
|
|
1294
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1295
|
+
return PowiainaNum.NaN.clone();
|
|
1296
|
+
}
|
|
1156
1297
|
if (this.eq(2)) return new PowiainaNum(4);
|
|
1157
1298
|
if (other.eq(0)) return PowiainaNum.ONE.clone();
|
|
1158
1299
|
var r;
|
|
@@ -1192,6 +1333,7 @@
|
|
|
1192
1333
|
var arrow = new PowiainaNum(arrow2);
|
|
1193
1334
|
var t = this.clone();
|
|
1194
1335
|
if (arrow.lt(0) || !arrow.isInt() || arrow.isNaN() || this.isNaN()) return function () {
|
|
1336
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1195
1337
|
return PowiainaNum.NaN.clone();
|
|
1196
1338
|
};
|
|
1197
1339
|
if (arrow.eq(0)) return function (other) {
|
|
@@ -1206,9 +1348,13 @@
|
|
|
1206
1348
|
var other = new PowiainaNum(other2);
|
|
1207
1349
|
var r;
|
|
1208
1350
|
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
|
|
1209
|
-
if (other.lt(PowiainaNum.ZERO))
|
|
1351
|
+
if (other.lt(PowiainaNum.ZERO)) {
|
|
1352
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1353
|
+
return PowiainaNum.NaN.clone();
|
|
1354
|
+
}
|
|
1210
1355
|
if (t.eq(PowiainaNum.ZERO)) {
|
|
1211
1356
|
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
|
|
1357
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
1212
1358
|
return PowiainaNum.NaN.clone();
|
|
1213
1359
|
}
|
|
1214
1360
|
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
|
|
@@ -1394,6 +1540,12 @@
|
|
|
1394
1540
|
var other = new PowiainaNum(x).abs();
|
|
1395
1541
|
return this.abs().cmp(other);
|
|
1396
1542
|
}
|
|
1543
|
+
/**
|
|
1544
|
+
* -1: `this` is smaller
|
|
1545
|
+
* 0: equals
|
|
1546
|
+
* 1: `x` is smaller
|
|
1547
|
+
* 2: NaN
|
|
1548
|
+
*/
|
|
1397
1549
|
}, {
|
|
1398
1550
|
key: "compare",
|
|
1399
1551
|
value: function compare(x) {
|
|
@@ -1401,6 +1553,7 @@
|
|
|
1401
1553
|
if (this.isNaN() || other.isNaN()) return 2;
|
|
1402
1554
|
if (this.sign < other.sign) return -1;
|
|
1403
1555
|
if (this.sign > other.sign) return 1;
|
|
1556
|
+
var t = this;
|
|
1404
1557
|
//this.sign = other.sign
|
|
1405
1558
|
var allneg = this.sign == -1 && other.sign == -1;
|
|
1406
1559
|
if (this.small && !other.small) return -1 * (allneg ? -1 : 1);
|
|
@@ -1412,6 +1565,18 @@
|
|
|
1412
1565
|
for (var i = 0; this.array.length - 1 - i >= 0 && other.array.length - 1 - i >= 0; i++) {
|
|
1413
1566
|
var op1 = this.array[this.array.length - 1 - i];
|
|
1414
1567
|
var op2 = other.array[other.array.length - 1 - i];
|
|
1568
|
+
if (op1.repeat === Infinity && op2.repeat === Infinity) {
|
|
1569
|
+
if (t.small === other.small) return 0;
|
|
1570
|
+
return other.small ? 1 : -1;
|
|
1571
|
+
}
|
|
1572
|
+
if (op1.repeat === Infinity) {
|
|
1573
|
+
result = 1;
|
|
1574
|
+
break;
|
|
1575
|
+
}
|
|
1576
|
+
if (op2.repeat === Infinity) {
|
|
1577
|
+
result = -1;
|
|
1578
|
+
break;
|
|
1579
|
+
}
|
|
1415
1580
|
var cmp = compareTuples([op1.megota, op1.expans, op1.arrow, op1.repeat], [op2.megota, op2.expans, op2.arrow, op2.repeat]);
|
|
1416
1581
|
if (cmp == 1) {
|
|
1417
1582
|
result = 1;
|
|
@@ -1459,6 +1624,16 @@
|
|
|
1459
1624
|
var t = this.cmp(other);
|
|
1460
1625
|
return t == 0 || t == 1;
|
|
1461
1626
|
}
|
|
1627
|
+
}, {
|
|
1628
|
+
key: "equals",
|
|
1629
|
+
value: function equals(other) {
|
|
1630
|
+
return this.eq(other);
|
|
1631
|
+
}
|
|
1632
|
+
}, {
|
|
1633
|
+
key: "notEquals",
|
|
1634
|
+
value: function notEquals(other) {
|
|
1635
|
+
return this.neq(other);
|
|
1636
|
+
}
|
|
1462
1637
|
}, {
|
|
1463
1638
|
key: "eq_tolerance",
|
|
1464
1639
|
value: function eq_tolerance(value) {
|
|
@@ -1468,6 +1643,7 @@
|
|
|
1468
1643
|
}
|
|
1469
1644
|
//#endregion
|
|
1470
1645
|
//#region geometry
|
|
1646
|
+
/**this function is indistinguishable above 4503599627370496*/
|
|
1471
1647
|
}, {
|
|
1472
1648
|
key: "sin",
|
|
1473
1649
|
value: function sin() {
|
|
@@ -1520,6 +1696,16 @@
|
|
|
1520
1696
|
a.small = !a.small;
|
|
1521
1697
|
return a;
|
|
1522
1698
|
}
|
|
1699
|
+
}, {
|
|
1700
|
+
key: "recip",
|
|
1701
|
+
value: function recip() {
|
|
1702
|
+
return this.rec();
|
|
1703
|
+
}
|
|
1704
|
+
}, {
|
|
1705
|
+
key: "reciprocate",
|
|
1706
|
+
value: function reciprocate() {
|
|
1707
|
+
return this.rec();
|
|
1708
|
+
}
|
|
1523
1709
|
}, {
|
|
1524
1710
|
key: "floor",
|
|
1525
1711
|
value: function floor() {
|
|
@@ -1560,6 +1746,9 @@
|
|
|
1560
1746
|
r.sign = this.sign;
|
|
1561
1747
|
return r;
|
|
1562
1748
|
}
|
|
1749
|
+
}, {
|
|
1750
|
+
key: "trunc",
|
|
1751
|
+
value:
|
|
1563
1752
|
/**
|
|
1564
1753
|
* Work like `Math.trunc`,
|
|
1565
1754
|
*
|
|
@@ -1572,15 +1761,10 @@
|
|
|
1572
1761
|
* new PowiainaNum(-1.114514).trunc() == new PowiainaNum(-1)
|
|
1573
1762
|
* @returns
|
|
1574
1763
|
*/
|
|
1575
|
-
|
|
1576
|
-
key: "trunc",
|
|
1577
|
-
value: function trunc() {
|
|
1764
|
+
function trunc() {
|
|
1578
1765
|
var y = this.clone();
|
|
1579
1766
|
return y.gte(0) ? y.floor() : y.ceil();
|
|
1580
1767
|
}
|
|
1581
|
-
/**
|
|
1582
|
-
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
1583
|
-
*/
|
|
1584
1768
|
}, {
|
|
1585
1769
|
key: "isNaN",
|
|
1586
1770
|
value: function (_isNaN) {
|
|
@@ -1643,10 +1827,164 @@
|
|
|
1643
1827
|
value: function isneg() {
|
|
1644
1828
|
return this.sign < 0;
|
|
1645
1829
|
}
|
|
1830
|
+
}, {
|
|
1831
|
+
key: "getOperatorIndex",
|
|
1832
|
+
value:
|
|
1833
|
+
//#endregion
|
|
1834
|
+
//#region operators
|
|
1835
|
+
/**
|
|
1836
|
+
* @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.
|
|
1837
|
+
*/
|
|
1838
|
+
function getOperatorIndex(arrow) {
|
|
1839
|
+
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1840
|
+
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1841
|
+
for (var i = 0; i < this.array.length; i++) {
|
|
1842
|
+
var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
|
|
1843
|
+
if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
|
|
1844
|
+
if (cmp == 1) return i - 0.5; // It's between [xx, xx,xx*,?,*xx]!
|
|
1845
|
+
}
|
|
1846
|
+
return this.array.length - 0.5;
|
|
1847
|
+
}
|
|
1848
|
+
/**
|
|
1849
|
+
* @returns number repeats of operators with given arguments.
|
|
1850
|
+
*/
|
|
1851
|
+
}, {
|
|
1852
|
+
key: "getOperator",
|
|
1853
|
+
value: function getOperator(arrow) {
|
|
1854
|
+
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1855
|
+
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1856
|
+
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1857
|
+
if (!this.array[index]) return 0;
|
|
1858
|
+
return this.array[index].repeat;
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Modify the repeat of operator
|
|
1862
|
+
* @param number val the repeat of operator will modify to array.
|
|
1863
|
+
* @returns bool Is the operators array changed?
|
|
1864
|
+
*/
|
|
1865
|
+
}, {
|
|
1866
|
+
key: "setOperator",
|
|
1867
|
+
value: function setOperator(val, arrow) {
|
|
1868
|
+
var expans = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1869
|
+
var megota = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
1870
|
+
// if (arrow!=0&&val==0) return false;
|
|
1871
|
+
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1872
|
+
if (!this.array[index]) {
|
|
1873
|
+
this.array.splice(Math.ceil(index), 0, {
|
|
1874
|
+
arrow: arrow,
|
|
1875
|
+
expans: expans,
|
|
1876
|
+
megota: megota,
|
|
1877
|
+
valuereplaced: expans === Infinity ? 1 : arrow == Infinity ? 0 : -1,
|
|
1878
|
+
repeat: val
|
|
1879
|
+
});
|
|
1880
|
+
return true;
|
|
1881
|
+
}
|
|
1882
|
+
this.array[index].repeat = val;
|
|
1883
|
+
// this.normalize()
|
|
1884
|
+
return false;
|
|
1885
|
+
}
|
|
1886
|
+
//#endregion
|
|
1887
|
+
//#region converters
|
|
1888
|
+
/**
|
|
1889
|
+
* Convert `this` to Javascript `number`
|
|
1890
|
+
*
|
|
1891
|
+
* returns `Infinity` when the number is greater than `Number.MAX_VALUE`
|
|
1892
|
+
*/
|
|
1893
|
+
}, {
|
|
1894
|
+
key: "toNumber",
|
|
1895
|
+
value: function toNumber() {
|
|
1896
|
+
if (this.sign == -1) return -this.neg().toNumber();
|
|
1897
|
+
if (this.small) return 1 / this.rec().toNumber();
|
|
1898
|
+
if (this.array.length > 2) return Infinity;
|
|
1899
|
+
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));
|
|
1900
|
+
return NaN;
|
|
1901
|
+
}
|
|
1902
|
+
/**
|
|
1903
|
+
* Convert `this` to a string
|
|
1904
|
+
*/
|
|
1905
|
+
}, {
|
|
1906
|
+
key: "toString_core",
|
|
1907
|
+
value: function toString_core() {
|
|
1908
|
+
if (this.isNaN()) return "NaN";
|
|
1909
|
+
if (this.sign == -1) return "-".concat(this.neg().toString());
|
|
1910
|
+
if (this.small) {
|
|
1911
|
+
if (this.isZero()) return "0";
|
|
1912
|
+
return "/".concat(this.rec().toString());
|
|
1913
|
+
}
|
|
1914
|
+
if (this.isInfi()) return "Infinity";
|
|
1915
|
+
// P^a (10{arrow,expans,megota})^repeation base
|
|
1916
|
+
var res = "";
|
|
1917
|
+
if (!this.layer) res += "";else if (this.layer < 3) res += "P".repeat(this.layer);else res += "P^" + this.layer + " ";
|
|
1918
|
+
for (var i = this.array.length - 1; i >= 0; i--) {
|
|
1919
|
+
var oper = this.array[i];
|
|
1920
|
+
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) : "", "}");
|
|
1921
|
+
if (oper.arrow == 1 && oper.expans == 1 && oper.megota == 1 && oper.repeat < 5) {
|
|
1922
|
+
calc = "e".repeat(oper.repeat);
|
|
1923
|
+
} else if (oper.arrow == 0 && oper.expans == 1 && oper.megota == 1) {
|
|
1924
|
+
calc = oper.repeat.toString();
|
|
1925
|
+
} else if (oper.repeat > 1) {
|
|
1926
|
+
calc = "(".concat(calc, ")^").concat(oper.repeat, " ");
|
|
1927
|
+
} else {
|
|
1928
|
+
calc = "".concat(calc);
|
|
1929
|
+
}
|
|
1930
|
+
res += "".concat(calc);
|
|
1931
|
+
}
|
|
1932
|
+
return res;
|
|
1933
|
+
}
|
|
1934
|
+
}, {
|
|
1935
|
+
key: "toString",
|
|
1936
|
+
value: function toString() {
|
|
1937
|
+
try {
|
|
1938
|
+
return this.toString_core();
|
|
1939
|
+
} catch (_b) {
|
|
1940
|
+
console.error("Checked error when converting to string");
|
|
1941
|
+
return "NaN";
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
}, {
|
|
1945
|
+
key: "toJSON",
|
|
1946
|
+
value:
|
|
1947
|
+
/**
|
|
1948
|
+
* Convert `this` to a JSON object
|
|
1949
|
+
* @returns a JSON object
|
|
1950
|
+
*/
|
|
1951
|
+
function toJSON() {
|
|
1952
|
+
return "PN" + this.toString();
|
|
1953
|
+
}
|
|
1954
|
+
}, {
|
|
1955
|
+
key: "arr01",
|
|
1956
|
+
get:
|
|
1957
|
+
/**
|
|
1958
|
+
* A property array value for version 0.1.x PowiainaNum.
|
|
1959
|
+
*/
|
|
1960
|
+
function get() {
|
|
1961
|
+
var res = [0];
|
|
1962
|
+
for (var i = 0; i < this.array.length; i++) {
|
|
1963
|
+
if (i == 0) res[0] = this.array[i].repeat;else {
|
|
1964
|
+
// @ts-ignore
|
|
1965
|
+
res[i] = [0, 0, 0, 0];
|
|
1966
|
+
// @ts-ignore
|
|
1967
|
+
res[i][0] = this.array[i].arrow == Infinity ? "x" : this.array[i].arrow;
|
|
1968
|
+
// @ts-ignore
|
|
1969
|
+
res[i][1] = this.array[i].repeat;
|
|
1970
|
+
// @ts-ignore
|
|
1971
|
+
res[i][2] = this.array[i].expans == Infinity ? "x" : this.array[i].expans;
|
|
1972
|
+
// @ts-ignore
|
|
1973
|
+
res[i][3] = this.array[i].megota;
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
return res;
|
|
1977
|
+
}
|
|
1978
|
+
//#endregion
|
|
1979
|
+
//#region useless functions
|
|
1980
|
+
/**
|
|
1981
|
+
* This function is for NaNe308, if you want to calculate G(x), use this function directly.
|
|
1982
|
+
*/
|
|
1646
1983
|
}, {
|
|
1647
1984
|
key: "normalize",
|
|
1648
1985
|
value:
|
|
1649
1986
|
//#endregion
|
|
1987
|
+
//#region other functions
|
|
1650
1988
|
/**
|
|
1651
1989
|
* Normalize functions will make this number convert into standard format.(it also change `this`, like [].sort)
|
|
1652
1990
|
* @returns normalized number
|
|
@@ -1655,9 +1993,14 @@
|
|
|
1655
1993
|
//TODO: normalize
|
|
1656
1994
|
var renormalize = true;
|
|
1657
1995
|
var x = this;
|
|
1658
|
-
|
|
1996
|
+
if (this.array === undefined) {
|
|
1997
|
+
x.array = [newOperator(NaN, 0, 1, 1)];
|
|
1998
|
+
}
|
|
1999
|
+
if (this.sign === undefined) this.sign = 0;
|
|
2000
|
+
if (this.layer === undefined) this.layer = 0;
|
|
2001
|
+
for (var i = 0; i < this.array.length; i++) {
|
|
1659
2002
|
// Check what is infinity
|
|
1660
|
-
if (this.array[
|
|
2003
|
+
if (this.array[i].repeat == Infinity) {
|
|
1661
2004
|
this.array = [{
|
|
1662
2005
|
arrow: 0,
|
|
1663
2006
|
expans: 1,
|
|
@@ -1668,8 +2011,8 @@
|
|
|
1668
2011
|
return this;
|
|
1669
2012
|
}
|
|
1670
2013
|
}
|
|
1671
|
-
for (var
|
|
1672
|
-
var e = x.array[
|
|
2014
|
+
for (var _i = 1; _i < x.array.length; ++_i) {
|
|
2015
|
+
var e = x.array[_i];
|
|
1673
2016
|
if (e.arrow === null || e.arrow === undefined) {
|
|
1674
2017
|
e.arrow = 0;
|
|
1675
2018
|
}
|
|
@@ -1700,28 +2043,28 @@
|
|
|
1700
2043
|
renormalize = false;
|
|
1701
2044
|
// Sort arrays.
|
|
1702
2045
|
this.array.sort(arraySortFunction);
|
|
1703
|
-
for (
|
|
1704
|
-
if (x.array[
|
|
2046
|
+
for (var _i2 = 1; _i2 < x.array.length - 1; ++_i2) {
|
|
2047
|
+
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) {
|
|
1705
2048
|
// same array's merge
|
|
1706
|
-
x.array[
|
|
1707
|
-
x.array.splice(
|
|
1708
|
-
--
|
|
2049
|
+
x.array[_i2].repeat += x.array[_i2 + 1].repeat;
|
|
2050
|
+
x.array.splice(_i2 + 1, 1);
|
|
2051
|
+
--_i2;
|
|
1709
2052
|
renormalize = true;
|
|
1710
2053
|
}
|
|
1711
2054
|
}
|
|
1712
|
-
for (
|
|
2055
|
+
for (var _i3 = 1; _i3 < x.array.length; ++_i3) {
|
|
1713
2056
|
// If there is a 0 repeat operator, remove it.
|
|
1714
|
-
if (x.array[
|
|
1715
|
-
x.array.splice(
|
|
1716
|
-
--
|
|
2057
|
+
if (x.array[_i3].arrow !== 0 && (x.array[_i3].repeat === 0 || x.array[_i3].repeat === null || x.array[_i3].repeat === undefined)) {
|
|
2058
|
+
x.array.splice(_i3, 1);
|
|
2059
|
+
--_i3;
|
|
1717
2060
|
continue;
|
|
1718
2061
|
}
|
|
1719
2062
|
// If there is a operator which arrow 0 and brace count >=2
|
|
1720
2063
|
// replace it as arrow replacement operaotr
|
|
1721
|
-
if (x.array[
|
|
1722
|
-
x.array[
|
|
1723
|
-
x.array[
|
|
1724
|
-
x.array[
|
|
2064
|
+
if (x.array[_i3].arrow == 0 && x.array[_i3].expans >= 2) {
|
|
2065
|
+
x.array[_i3].arrow = Infinity;
|
|
2066
|
+
x.array[_i3].valuereplaced = 0;
|
|
2067
|
+
x.array[_i3].expans = x.array[_i3].expans - 1;
|
|
1725
2068
|
}
|
|
1726
2069
|
}
|
|
1727
2070
|
if (x.array.length > PowiainaNum.maxOps) x.array.splice(1, x.array.length - PowiainaNum.maxOps); // max operators check
|
|
@@ -1751,6 +2094,11 @@
|
|
|
1751
2094
|
this.small = !this.small;
|
|
1752
2095
|
renormalize = true;
|
|
1753
2096
|
}
|
|
2097
|
+
// for a = 1, small should false.
|
|
2098
|
+
if (this.array.length == 1 && this.array[0].repeat == 1 && this.small) {
|
|
2099
|
+
this.small = false;
|
|
2100
|
+
renormalize = true;
|
|
2101
|
+
}
|
|
1754
2102
|
// for any 10{X>9e15}10, replace into 10{!}X;
|
|
1755
2103
|
if (this.array.length >= 2 && this.array[1].arrow >= MSI) {
|
|
1756
2104
|
this.array[0].repeat = this.array[1].arrow;
|
|
@@ -1806,61 +2154,6 @@
|
|
|
1806
2154
|
} while (renormalize);
|
|
1807
2155
|
return this;
|
|
1808
2156
|
}
|
|
1809
|
-
//#region operators
|
|
1810
|
-
/**
|
|
1811
|
-
* @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.
|
|
1812
|
-
*/
|
|
1813
|
-
}, {
|
|
1814
|
-
key: "getOperatorIndex",
|
|
1815
|
-
value: function getOperatorIndex(arrow) {
|
|
1816
|
-
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1817
|
-
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1818
|
-
for (var i = 0; i < this.array.length; i++) {
|
|
1819
|
-
var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
|
|
1820
|
-
if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
|
|
1821
|
-
if (cmp == 1) return i - 0.5; // It's between [xx, xx,xx*,?,*xx]!
|
|
1822
|
-
}
|
|
1823
|
-
return this.array.length - 0.5;
|
|
1824
|
-
}
|
|
1825
|
-
/**
|
|
1826
|
-
* @returns number repeats of operators with given arguments.
|
|
1827
|
-
*/
|
|
1828
|
-
}, {
|
|
1829
|
-
key: "getOperator",
|
|
1830
|
-
value: function getOperator(arrow) {
|
|
1831
|
-
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1832
|
-
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1833
|
-
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1834
|
-
if (!this.array[index]) return 0;
|
|
1835
|
-
return this.array[index].repeat;
|
|
1836
|
-
}
|
|
1837
|
-
/**
|
|
1838
|
-
* Modify the repeat of operator
|
|
1839
|
-
* @param number val the repeat of operator will modify to array.
|
|
1840
|
-
* @returns bool Is the operators array changed?
|
|
1841
|
-
*/
|
|
1842
|
-
}, {
|
|
1843
|
-
key: "setOperator",
|
|
1844
|
-
value: function setOperator(val, arrow) {
|
|
1845
|
-
var expans = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1846
|
-
var megota = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
1847
|
-
// if (arrow!=0&&val==0) return false;
|
|
1848
|
-
var index = this.getOperatorIndex(arrow, expans, megota);
|
|
1849
|
-
if (!this.array[index]) {
|
|
1850
|
-
this.array.splice(Math.ceil(index), 0, {
|
|
1851
|
-
arrow: arrow,
|
|
1852
|
-
expans: expans,
|
|
1853
|
-
megota: megota,
|
|
1854
|
-
valuereplaced: expans === Infinity ? 1 : arrow == Infinity ? 0 : -1,
|
|
1855
|
-
repeat: val
|
|
1856
|
-
});
|
|
1857
|
-
return true;
|
|
1858
|
-
}
|
|
1859
|
-
this.array[index].repeat = val;
|
|
1860
|
-
// this.normalize()
|
|
1861
|
-
return false;
|
|
1862
|
-
}
|
|
1863
|
-
//#endregion
|
|
1864
2157
|
/**
|
|
1865
2158
|
* @returns a PowiainaNum object which deep copied from `this` object.
|
|
1866
2159
|
*/
|
|
@@ -1879,6 +2172,9 @@
|
|
|
1879
2172
|
}, {
|
|
1880
2173
|
key: "resetFromObject",
|
|
1881
2174
|
value: function resetFromObject(powlikeObject) {
|
|
2175
|
+
if (!powlikeObject.array) {
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
1882
2178
|
this.array = [];
|
|
1883
2179
|
for (var i = 0; i < powlikeObject.array.length; i++) {
|
|
1884
2180
|
this.array[i] = {
|
|
@@ -1894,107 +2190,56 @@
|
|
|
1894
2190
|
this.layer = powlikeObject.layer;
|
|
1895
2191
|
return this;
|
|
1896
2192
|
}
|
|
1897
|
-
//#region converters
|
|
1898
|
-
/**
|
|
1899
|
-
* Convert `this` to Javascript `number`
|
|
1900
|
-
*
|
|
1901
|
-
* returns `Infinity` when the number is greater than `Number.MAX_VALUE`
|
|
1902
|
-
*/
|
|
1903
|
-
}, {
|
|
1904
|
-
key: "toNumber",
|
|
1905
|
-
value: function toNumber() {
|
|
1906
|
-
if (this.sign == -1) return -this.neg().toNumber();
|
|
1907
|
-
if (this.small) return 1 / this.rec().toNumber();
|
|
1908
|
-
if (this.array.length > 2) return Infinity;
|
|
1909
|
-
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));
|
|
1910
|
-
return NaN;
|
|
1911
|
-
}
|
|
1912
|
-
/**
|
|
1913
|
-
* Convert `this` to a string
|
|
1914
|
-
*/
|
|
1915
|
-
}, {
|
|
1916
|
-
key: "toString",
|
|
1917
|
-
value: function toString() {
|
|
1918
|
-
if (this.isNaN()) return "NaN";
|
|
1919
|
-
if (this.sign == -1) return "-".concat(this.neg().toString());
|
|
1920
|
-
if (this.small) {
|
|
1921
|
-
if (this.isZero()) return "0";
|
|
1922
|
-
return "/".concat(this.rec().toString());
|
|
1923
|
-
}
|
|
1924
|
-
if (this.isInfi()) return "Infinity";
|
|
1925
|
-
// P^a (10{arrow,expans,megota})^repeation base
|
|
1926
|
-
var res = "";
|
|
1927
|
-
if (!this.layer) res += "";else if (this.layer < 3) res += "P".repeat(this.layer);else res += "P^" + this.layer + " ";
|
|
1928
|
-
for (var i = this.array.length - 1; i >= 0; i--) {
|
|
1929
|
-
var oper = this.array[i];
|
|
1930
|
-
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) : "", "}");
|
|
1931
|
-
if (oper.arrow == 1 && oper.expans == 1 && oper.megota == 1 && oper.repeat < 5) {
|
|
1932
|
-
calc = "e".repeat(oper.repeat);
|
|
1933
|
-
} else if (oper.arrow == 0 && oper.expans == 1 && oper.megota == 1) {
|
|
1934
|
-
calc = oper.repeat.toString();
|
|
1935
|
-
} else if (oper.repeat > 1) {
|
|
1936
|
-
calc = "(".concat(calc, ")^").concat(oper.repeat, " ");
|
|
1937
|
-
} else {
|
|
1938
|
-
calc = "".concat(calc);
|
|
1939
|
-
}
|
|
1940
|
-
res += "".concat(calc);
|
|
1941
|
-
}
|
|
1942
|
-
return res;
|
|
1943
|
-
}
|
|
1944
|
-
}, {
|
|
1945
|
-
key: "toJSON",
|
|
1946
|
-
value:
|
|
1947
|
-
/**
|
|
1948
|
-
* Convert `this` to a JSON object
|
|
1949
|
-
* @returns a JSON object
|
|
1950
|
-
*/
|
|
1951
|
-
function toJSON() {
|
|
1952
|
-
return "PN" + this.toString();
|
|
1953
|
-
}
|
|
1954
|
-
}, {
|
|
1955
|
-
key: "arr01",
|
|
1956
|
-
get:
|
|
1957
|
-
/**
|
|
1958
|
-
* A property array value for version 0.1.x PowiainaNum.
|
|
1959
|
-
*/
|
|
1960
|
-
function get() {
|
|
1961
|
-
var res = [0];
|
|
1962
|
-
for (var i = 0; i < this.array.length; i++) {
|
|
1963
|
-
if (i == 0) res[0] = this.array[i].repeat;else {
|
|
1964
|
-
// @ts-ignore
|
|
1965
|
-
res[i] = [0, 0, 0, 0];
|
|
1966
|
-
// @ts-ignore
|
|
1967
|
-
res[i][0] = this.array[i].arrow == Infinity ? "x" : this.array[i].arrow;
|
|
1968
|
-
// @ts-ignore
|
|
1969
|
-
res[i][1] = this.array[i].repeat;
|
|
1970
|
-
// @ts-ignore
|
|
1971
|
-
res[i][2] = this.array[i].expans == Infinity ? "x" : this.array[i].expans;
|
|
1972
|
-
// @ts-ignore
|
|
1973
|
-
res[i][3] = this.array[i].megota;
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
return res;
|
|
1977
|
-
}
|
|
1978
2193
|
}], [{
|
|
1979
2194
|
key: "add",
|
|
1980
2195
|
value: function add(t, other) {
|
|
1981
2196
|
return new PowiainaNum(t).add(other);
|
|
1982
2197
|
}
|
|
2198
|
+
}, {
|
|
2199
|
+
key: "plus",
|
|
2200
|
+
value: function plus(t, other) {
|
|
2201
|
+
return new PowiainaNum(t).add(other);
|
|
2202
|
+
}
|
|
1983
2203
|
}, {
|
|
1984
2204
|
key: "sub",
|
|
1985
2205
|
value: function sub(t, other) {
|
|
1986
2206
|
return new PowiainaNum(t).sub(other);
|
|
1987
2207
|
}
|
|
2208
|
+
}, {
|
|
2209
|
+
key: "minus",
|
|
2210
|
+
value: function minus(t, other) {
|
|
2211
|
+
return new PowiainaNum(t).sub(other);
|
|
2212
|
+
}
|
|
1988
2213
|
}, {
|
|
1989
2214
|
key: "mul",
|
|
1990
2215
|
value: function mul(t, other) {
|
|
1991
2216
|
return new PowiainaNum(t).mul(other);
|
|
1992
2217
|
}
|
|
2218
|
+
}, {
|
|
2219
|
+
key: "times",
|
|
2220
|
+
value: function times(t, other) {
|
|
2221
|
+
return new PowiainaNum(t).mul(other);
|
|
2222
|
+
}
|
|
1993
2223
|
}, {
|
|
1994
2224
|
key: "div",
|
|
1995
2225
|
value: function div(t, other) {
|
|
1996
2226
|
return new PowiainaNum(t).div(other);
|
|
1997
2227
|
}
|
|
2228
|
+
}, {
|
|
2229
|
+
key: "divide",
|
|
2230
|
+
value: function divide(t, other) {
|
|
2231
|
+
return new PowiainaNum(t).div(other);
|
|
2232
|
+
}
|
|
2233
|
+
}, {
|
|
2234
|
+
key: "mod",
|
|
2235
|
+
value: function mod(x, y) {
|
|
2236
|
+
return new PowiainaNum(x).mod(y);
|
|
2237
|
+
}
|
|
2238
|
+
}, {
|
|
2239
|
+
key: "modulus",
|
|
2240
|
+
value: function modulus(x, y) {
|
|
2241
|
+
return new PowiainaNum(x).mod(y);
|
|
2242
|
+
}
|
|
1998
2243
|
}, {
|
|
1999
2244
|
key: "pow",
|
|
2000
2245
|
value: function pow(t, other) {
|
|
@@ -2026,6 +2271,17 @@
|
|
|
2026
2271
|
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.E;
|
|
2027
2272
|
return new PowiainaNum(t).log(base);
|
|
2028
2273
|
}
|
|
2274
|
+
}, {
|
|
2275
|
+
key: "log2",
|
|
2276
|
+
value: function log2(t) {
|
|
2277
|
+
return new PowiainaNum(t).log2();
|
|
2278
|
+
}
|
|
2279
|
+
}, {
|
|
2280
|
+
key: "logBase",
|
|
2281
|
+
value: function logBase(t) {
|
|
2282
|
+
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Math.E;
|
|
2283
|
+
return new PowiainaNum(t).log(base);
|
|
2284
|
+
}
|
|
2029
2285
|
}, {
|
|
2030
2286
|
key: "pLog10",
|
|
2031
2287
|
value: function pLog10(t) {
|
|
@@ -2177,6 +2433,27 @@
|
|
|
2177
2433
|
};
|
|
2178
2434
|
}
|
|
2179
2435
|
}
|
|
2436
|
+
}, {
|
|
2437
|
+
key: "pentate",
|
|
2438
|
+
value: function pentate(x, other, payload) {
|
|
2439
|
+
return new PowiainaNum(x).arrow(3)(other, payload);
|
|
2440
|
+
}
|
|
2441
|
+
}, {
|
|
2442
|
+
key: "hexate",
|
|
2443
|
+
value: function hexate(x, other, payload) {
|
|
2444
|
+
return new PowiainaNum(x).arrow(4)(other, payload);
|
|
2445
|
+
}
|
|
2446
|
+
}, {
|
|
2447
|
+
key: "pent",
|
|
2448
|
+
value: function pent(x, other, payload) {
|
|
2449
|
+
return new PowiainaNum(x).arrow(3)(other, payload);
|
|
2450
|
+
}
|
|
2451
|
+
}, {
|
|
2452
|
+
key: "penta_log",
|
|
2453
|
+
value: function penta_log(x) {
|
|
2454
|
+
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
|
|
2455
|
+
return new PowiainaNum(x).anyarrow_log(3)(base);
|
|
2456
|
+
}
|
|
2180
2457
|
}, {
|
|
2181
2458
|
key: "expansion",
|
|
2182
2459
|
value: function expansion(t, other) {
|
|
@@ -2232,7 +2509,10 @@
|
|
|
2232
2509
|
if (base.eq(1)) return new PowiainaNum(1);
|
|
2233
2510
|
if (power.eq(1)) return new PowiainaNum(base);
|
|
2234
2511
|
if (power.isZero()) return new PowiainaNum(1);
|
|
2235
|
-
if (base.lt(0))
|
|
2512
|
+
if (base.lt(0)) {
|
|
2513
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
2514
|
+
return PowiainaNum.NaN.clone();
|
|
2515
|
+
}
|
|
2236
2516
|
// // check infinite
|
|
2237
2517
|
// let sufpowiaina = args.slice(4);
|
|
2238
2518
|
// if (sufpowiaina.filter((f) => new PowiainaNum(f).gte(2)).length > 0) {
|
|
@@ -2275,9 +2555,6 @@
|
|
|
2275
2555
|
if (a == 0 && e == 1 && m > 1) {
|
|
2276
2556
|
return [1, 1 / 0, m - 1];
|
|
2277
2557
|
}
|
|
2278
|
-
if (e == 0 && m > 1) {
|
|
2279
|
-
return [1, 1 / 0, m - 1];
|
|
2280
|
-
}
|
|
2281
2558
|
return [a, e, m];
|
|
2282
2559
|
}
|
|
2283
2560
|
if (megota.gt(MSI)) {
|
|
@@ -2291,8 +2568,7 @@
|
|
|
2291
2568
|
return x.toString();
|
|
2292
2569
|
}
|
|
2293
2570
|
function getMSIForm(arrow, expans, megota) {
|
|
2294
|
-
|
|
2295
|
-
return "10{".concat(infToBang(conv[0]), ",").concat(infToBang(conv[1]), ",").concat(conv[2], "}").concat(MSI);
|
|
2571
|
+
return "10{".concat(infToBang(arrow), ",").concat(infToBang(expans), ",").concat(megota, "}").concat(MSI);
|
|
2296
2572
|
}
|
|
2297
2573
|
var t = base.clone();
|
|
2298
2574
|
var arrows = new PowiainaNum(readArg(0));
|
|
@@ -2300,20 +2576,13 @@
|
|
|
2300
2576
|
var _r, _r2;
|
|
2301
2577
|
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
2302
2578
|
console.log("".concat("-".repeat(depth), " {").concat(base2, ",").concat(power2, ",").concat(arrow2, ",").concat(expans2, ",").concat(megota2, "}"));
|
|
2303
|
-
if (depth >= 200) {
|
|
2304
|
-
return new PowiainaNum({
|
|
2305
|
-
layer: 0,
|
|
2306
|
-
array: [newOperator(10), newOperator(1, new PowiainaNum(arrow2).clampMax(MSI).toNumber(), new PowiainaNum(expans2).clampMax(MSI).toNumber(), new PowiainaNum(megota2).clampMax(MSI).toNumber())],
|
|
2307
|
-
sign: 1,
|
|
2308
|
-
small: false
|
|
2309
|
-
}).normalize();
|
|
2310
|
-
}
|
|
2311
2579
|
var other = new PowiainaNum(other2);
|
|
2312
2580
|
var r;
|
|
2313
2581
|
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
|
|
2314
2582
|
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
|
|
2315
2583
|
if (t.eq(PowiainaNum.ZERO)) {
|
|
2316
2584
|
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
|
|
2585
|
+
if (PowiainaNum.throwErrorOnResultNaN) throw new Error("NaN");
|
|
2317
2586
|
return PowiainaNum.NaN.clone();
|
|
2318
2587
|
}
|
|
2319
2588
|
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
|
|
@@ -2325,7 +2594,7 @@
|
|
|
2325
2594
|
}
|
|
2326
2595
|
if (expans.eq(0)) {
|
|
2327
2596
|
return PowiainaNum.BEAF(t, t, t, power, megota.sub(1), powiaina2, depth + 1);
|
|
2328
|
-
// {this, this, power,
|
|
2597
|
+
// {this, this, this, power, megota-1}
|
|
2329
2598
|
}
|
|
2330
2599
|
if (megota.eq(0)) {
|
|
2331
2600
|
return PowiainaNum.BEAF(t, t, t, t, expans, new PowiainaNum(powiaina2).sub(1), depth + 1);
|
|
@@ -2444,6 +2713,84 @@
|
|
|
2444
2713
|
value: function clampMax() {
|
|
2445
2714
|
return PowiainaNum.min.apply(PowiainaNum, arguments);
|
|
2446
2715
|
}
|
|
2716
|
+
}, {
|
|
2717
|
+
key: "eq",
|
|
2718
|
+
value: function eq(a, o) {
|
|
2719
|
+
return new PowiainaNum(a).eq(o);
|
|
2720
|
+
}
|
|
2721
|
+
}, {
|
|
2722
|
+
key: "equals",
|
|
2723
|
+
value: function equals(a, o) {
|
|
2724
|
+
return new PowiainaNum(a).eq(o);
|
|
2725
|
+
}
|
|
2726
|
+
}, {
|
|
2727
|
+
key: "neq",
|
|
2728
|
+
value: function neq(a, o) {
|
|
2729
|
+
return new PowiainaNum(a).neq(o);
|
|
2730
|
+
}
|
|
2731
|
+
}, {
|
|
2732
|
+
key: "notEquals",
|
|
2733
|
+
value: function notEquals(a, o) {
|
|
2734
|
+
return new PowiainaNum(a).notEquals(o);
|
|
2735
|
+
}
|
|
2736
|
+
}, {
|
|
2737
|
+
key: "lt",
|
|
2738
|
+
value: function lt(a, o) {
|
|
2739
|
+
return new PowiainaNum(a).lt(o);
|
|
2740
|
+
}
|
|
2741
|
+
}, {
|
|
2742
|
+
key: "gt",
|
|
2743
|
+
value: function gt(a, o) {
|
|
2744
|
+
return new PowiainaNum(a).gt(o);
|
|
2745
|
+
}
|
|
2746
|
+
}, {
|
|
2747
|
+
key: "lte",
|
|
2748
|
+
value: function lte(a, o) {
|
|
2749
|
+
return new PowiainaNum(a).lte(o);
|
|
2750
|
+
}
|
|
2751
|
+
}, {
|
|
2752
|
+
key: "gte",
|
|
2753
|
+
value: function gte(a, o) {
|
|
2754
|
+
return new PowiainaNum(a).gte(o);
|
|
2755
|
+
}
|
|
2756
|
+
}, {
|
|
2757
|
+
key: "rec",
|
|
2758
|
+
value: function rec(t) {
|
|
2759
|
+
return new PowiainaNum(t).rec();
|
|
2760
|
+
}
|
|
2761
|
+
}, {
|
|
2762
|
+
key: "recip",
|
|
2763
|
+
value: function recip(t) {
|
|
2764
|
+
return new PowiainaNum(t).rec();
|
|
2765
|
+
}
|
|
2766
|
+
}, {
|
|
2767
|
+
key: "reciprocate",
|
|
2768
|
+
value: function reciprocate(t) {
|
|
2769
|
+
return new PowiainaNum(t).rec();
|
|
2770
|
+
}
|
|
2771
|
+
}, {
|
|
2772
|
+
key: "floor",
|
|
2773
|
+
value: function floor(x) {
|
|
2774
|
+
return new PowiainaNum(x).floor();
|
|
2775
|
+
}
|
|
2776
|
+
}, {
|
|
2777
|
+
key: "ceil",
|
|
2778
|
+
value: function ceil(x) {
|
|
2779
|
+
return new PowiainaNum(x).ceil();
|
|
2780
|
+
}
|
|
2781
|
+
}, {
|
|
2782
|
+
key: "round",
|
|
2783
|
+
value: function round(x) {
|
|
2784
|
+
return new PowiainaNum(x).round();
|
|
2785
|
+
}
|
|
2786
|
+
}, {
|
|
2787
|
+
key: "trunc",
|
|
2788
|
+
value: function trunc(x) {
|
|
2789
|
+
return new PowiainaNum(x).trunc();
|
|
2790
|
+
}
|
|
2791
|
+
/**
|
|
2792
|
+
* @returns if this<other, return -1, if this=other, return 0, if this>other, return 1, if this!<=>, return 2
|
|
2793
|
+
*/
|
|
2447
2794
|
}, {
|
|
2448
2795
|
key: "sign",
|
|
2449
2796
|
value: function sign(a) {
|
|
@@ -2457,7 +2804,19 @@
|
|
|
2457
2804
|
}, {
|
|
2458
2805
|
key: "fromNumber",
|
|
2459
2806
|
value: function fromNumber(x) {
|
|
2460
|
-
var obj = new PowiainaNum();
|
|
2807
|
+
var obj = new PowiainaNum();
|
|
2808
|
+
obj.resetFromObject({
|
|
2809
|
+
array: [{
|
|
2810
|
+
arrow: 0,
|
|
2811
|
+
expans: 1,
|
|
2812
|
+
megota: 1,
|
|
2813
|
+
repeat: NaN
|
|
2814
|
+
}],
|
|
2815
|
+
small: false,
|
|
2816
|
+
layer: 0,
|
|
2817
|
+
sign: 0
|
|
2818
|
+
});
|
|
2819
|
+
if (Number.isNaN(x)) return obj;
|
|
2461
2820
|
if (x < 0) obj.sign = -1; // negative
|
|
2462
2821
|
else if (x == 0) {
|
|
2463
2822
|
obj.sign = 0;
|
|
@@ -2485,10 +2844,26 @@
|
|
|
2485
2844
|
}, {
|
|
2486
2845
|
key: "fromString",
|
|
2487
2846
|
value: function fromString(input) {
|
|
2847
|
+
if (PowiainaNum.usingBreakEternityLikeFromString && BE_REGEX.test(input)) {
|
|
2848
|
+
/*
|
|
2849
|
+
* 0i00000000a7 says that eee-3000 will wrongly parse to 1. So i added this
|
|
2850
|
+
*/
|
|
2851
|
+
var a = input.match(/(e+-)(\d+(.\d+)?)/);
|
|
2852
|
+
if (a) {
|
|
2853
|
+
var e_s = a[1].length;
|
|
2854
|
+
input = "e-" + "e".repeat(e_s - 1) + a[2];
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
return this.fromString_core(input);
|
|
2858
|
+
}
|
|
2859
|
+
}, {
|
|
2860
|
+
key: "fromString_core",
|
|
2861
|
+
value: function fromString_core(input) {
|
|
2488
2862
|
var _b, _c, _d, _e, _f, _g;
|
|
2489
|
-
var x = new PowiainaNum();
|
|
2863
|
+
var x = new PowiainaNum(NaN);
|
|
2490
2864
|
// Judge the string was a number
|
|
2491
2865
|
if (input.startsWith("PN")) input = input.substring(2);
|
|
2866
|
+
if (input == "NaN") return PowiainaNum.NaN.clone();
|
|
2492
2867
|
input = input.replace(/J\^(\d+)/g, "(10{!})^$1");
|
|
2493
2868
|
input = input.replace(/J/g, "10{!}");
|
|
2494
2869
|
input = input.replace(/K\^(\d+)/g, "(10{1,2})^$1");
|
|
@@ -2499,17 +2874,20 @@
|
|
|
2499
2874
|
input = input.replace(/M/g, "10{!,2}");
|
|
2500
2875
|
input = input.replace(/N\^(\d+)/g, "(10{1,!})^$1");
|
|
2501
2876
|
input = input.replace(/N/g, "10{1,!}");
|
|
2877
|
+
if (/^.*e-.*(e|\^).*/.test(input)) {
|
|
2878
|
+
input = "/10^" + input.substring(input.indexOf("e-"));
|
|
2879
|
+
}
|
|
2502
2880
|
if (!isNaN(Number(input))) {
|
|
2503
2881
|
var res = Number(input);
|
|
2504
|
-
var
|
|
2882
|
+
var a = false;
|
|
2505
2883
|
if (res == 0) {
|
|
2506
2884
|
if (/^((0)|(0*\.0+e\d+)|(0*\.0*))$/.test(input)) {
|
|
2507
|
-
|
|
2885
|
+
a = true;
|
|
2508
2886
|
}
|
|
2509
2887
|
} else {
|
|
2510
|
-
|
|
2888
|
+
a = true;
|
|
2511
2889
|
}
|
|
2512
|
-
if (!
|
|
2890
|
+
if (!a) {
|
|
2513
2891
|
var m = input.search(/e/);
|
|
2514
2892
|
var exponent = input.substring((m == -1 ? input.length : m) + 1);
|
|
2515
2893
|
var mantissa = input.substring(0, m == -1 ? undefined : m);
|
|
@@ -2519,11 +2897,11 @@
|
|
|
2519
2897
|
// Is regular number gte 1:
|
|
2520
2898
|
if (Number(mantissa) >= 1) {
|
|
2521
2899
|
// check The mantissa is very long?
|
|
2522
|
-
var log10mant = mantissa.length >= LONG_STRING_MIN_LENGTH ? log10LongString(mantissa) : Math.log10(Number(mantissa));
|
|
2523
|
-
var log10int = Math.floor(log10mant);
|
|
2524
|
-
var log10float = log10mant - log10int;
|
|
2900
|
+
var log10mant = mantissa.length >= LONG_STRING_MIN_LENGTH ? log10LongString(mantissa) : Math.log10(Number(mantissa)); // sample 10
|
|
2901
|
+
var log10int = Math.floor(log10mant); // sample 1
|
|
2902
|
+
var log10float = log10mant - log10int; // sample 0;
|
|
2525
2903
|
mantissaME[0] = Math.pow(10, log10float);
|
|
2526
|
-
mantissaME[1] +=
|
|
2904
|
+
mantissaME[1] += log10int;
|
|
2527
2905
|
} else {
|
|
2528
2906
|
// If not , count how many zeros until reached non-zero numbers
|
|
2529
2907
|
var zeros = countLeadingZerosAfterDecimal(mantissa);
|
|
@@ -2538,7 +2916,7 @@
|
|
|
2538
2916
|
// /((a*10^b)^-1) = /(a^-1*10^-b) = /(a^-1 * 10 * 10^(-b-1))
|
|
2539
2917
|
return PowiainaNum.pow(10, -mantissaME[1] - 1).mul(Math.pow(mantissaME[0], -1) * 10).rec();
|
|
2540
2918
|
}
|
|
2541
|
-
if (isFinite(res) &&
|
|
2919
|
+
if (isFinite(res) && a) {
|
|
2542
2920
|
x = PowiainaNum.fromNumber(Number(input));
|
|
2543
2921
|
return x;
|
|
2544
2922
|
}
|
|
@@ -2555,6 +2933,7 @@
|
|
|
2555
2933
|
return x;
|
|
2556
2934
|
}
|
|
2557
2935
|
input = replaceETo10(input);
|
|
2936
|
+
input = removeCommasOutsideBraces(input);
|
|
2558
2937
|
if (!isPowiainaNum.test(input)) {
|
|
2559
2938
|
throw powiainaNumError + "malformed input: " + input;
|
|
2560
2939
|
}
|
|
@@ -2567,28 +2946,31 @@
|
|
|
2567
2946
|
input = input.substring(numSigns);
|
|
2568
2947
|
}
|
|
2569
2948
|
if (input[0] == "/") {
|
|
2570
|
-
var
|
|
2571
|
-
var
|
|
2572
|
-
recipIt = ((_e = (_d =
|
|
2573
|
-
input = input.substring(
|
|
2949
|
+
var _numSigns = input.search(/[^\/]/);
|
|
2950
|
+
var _signs = input.substring(0, _numSigns);
|
|
2951
|
+
recipIt = ((_e = (_d = _signs.match(/\//g)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) % 2 == 1;
|
|
2952
|
+
input = input.substring(_numSigns);
|
|
2574
2953
|
}
|
|
2575
2954
|
if (input == "NaN") x.array = [newOperator(NaN)];else if (input == "Infinity") x.array = [newOperator(Infinity)];else {
|
|
2576
2955
|
x.sign = 1;
|
|
2577
2956
|
x.array = [newOperator(0)];
|
|
2578
|
-
var
|
|
2957
|
+
var _a3, b, c, d;
|
|
2579
2958
|
if (input[0] == "P") {
|
|
2580
2959
|
if (input[1] == "^") {
|
|
2581
|
-
|
|
2582
|
-
x.layer = Number(input.substring(2,
|
|
2583
|
-
input = input.substring(
|
|
2960
|
+
_a3 = input.substring(2).search(/[^0-9]/) + 2;
|
|
2961
|
+
x.layer = Number(input.substring(2, _a3));
|
|
2962
|
+
input = input.substring(_a3 + 1);
|
|
2584
2963
|
} else {
|
|
2585
|
-
|
|
2586
|
-
x.layer =
|
|
2587
|
-
input = input.substring(
|
|
2964
|
+
_a3 = input.search(/[^P]/);
|
|
2965
|
+
x.layer = _a3;
|
|
2966
|
+
input = input.substring(_a3);
|
|
2588
2967
|
}
|
|
2589
2968
|
}
|
|
2590
2969
|
while (input) {
|
|
2591
2970
|
if (/^(\(?10[\^\{])/.test(input)) {
|
|
2971
|
+
var arrows = void 0,
|
|
2972
|
+
expans = void 0,
|
|
2973
|
+
megota = void 0;
|
|
2592
2974
|
/*
|
|
2593
2975
|
10^ - 匹配
|
|
2594
2976
|
10{ - 匹配
|
|
@@ -2599,30 +2981,29 @@
|
|
|
2599
2981
|
*/
|
|
2600
2982
|
if (input[0] == "(") input = input.substring(1);
|
|
2601
2983
|
//cutted, 10^.... or 10{....
|
|
2602
|
-
var arrows, expans, megota;
|
|
2603
2984
|
if (input[2] == "^") {
|
|
2604
|
-
|
|
2985
|
+
_a3 = input.substring(2).search(/[^\^]/);
|
|
2605
2986
|
//cut input to ^^...^^, and search how numbers
|
|
2606
|
-
arrows =
|
|
2987
|
+
arrows = _a3;
|
|
2607
2988
|
// 10^^^
|
|
2608
|
-
b =
|
|
2989
|
+
b = _a3 + 2; // b points to after ^'s.
|
|
2609
2990
|
} else {
|
|
2610
2991
|
// 10{...}
|
|
2611
|
-
|
|
2992
|
+
_a3 = input.indexOf("}");
|
|
2612
2993
|
// select contents between {...}
|
|
2613
|
-
var tmp = input.substring(3,
|
|
2994
|
+
var tmp = input.substring(3, _a3).split(",");
|
|
2614
2995
|
arrows = Number(tmp[0] == "!" ? Infinity : tmp[0]);
|
|
2615
2996
|
expans = Number((_f = tmp[1] == "!" ? Infinity : tmp[1]) !== null && _f !== void 0 ? _f : 1);
|
|
2616
2997
|
megota = Number((_g = tmp[2]) !== null && _g !== void 0 ? _g : 1);
|
|
2617
|
-
b =
|
|
2998
|
+
b = _a3 + 1;
|
|
2618
2999
|
// b points to after }.
|
|
2619
3000
|
}
|
|
2620
3001
|
input = input.substring(b);
|
|
2621
3002
|
if (input[0] == ")") {
|
|
2622
3003
|
// )^....<Space>
|
|
2623
|
-
|
|
2624
|
-
c = Number(input.substring(2,
|
|
2625
|
-
input = input.substring(
|
|
3004
|
+
_a3 = input.indexOf(" ");
|
|
3005
|
+
c = Number(input.substring(2, _a3)); // Select contents between )^....<Space>
|
|
3006
|
+
input = input.substring(_a3 + 1); // c points to after <Space>
|
|
2626
3007
|
} else {
|
|
2627
3008
|
c = 1; // There is only spaces, count as <ONE>
|
|
2628
3009
|
}
|
|
@@ -2633,21 +3014,21 @@
|
|
|
2633
3014
|
x.array.splice(1, 0, newOperator(c, 1, expans, megota));
|
|
2634
3015
|
}
|
|
2635
3016
|
} else if (arrows == 2 && expans == 1 && megota == 1) {
|
|
2636
|
-
|
|
3017
|
+
_a3 = x.array.length >= 2 && x.array[1].arrow == 1 ? x.array[1].repeat : 0;
|
|
2637
3018
|
b = x.array[0].repeat;
|
|
2638
|
-
if (b >= 1e10) ++
|
|
2639
|
-
if (b >= 10) ++
|
|
2640
|
-
x.array[0].repeat =
|
|
3019
|
+
if (b >= 1e10) ++_a3;
|
|
3020
|
+
if (b >= 10) ++_a3;
|
|
3021
|
+
x.array[0].repeat = _a3;
|
|
2641
3022
|
if (x.array.length >= 2 && x.array[1].arrow == 1) x.array.splice(1, 1);
|
|
2642
3023
|
d = x.getOperatorIndex(2);
|
|
2643
3024
|
if (Number.isInteger(d)) x.array[d].repeat += c;else x.array.splice(Math.ceil(d), 0, newOperator(c, 2, expans, megota));
|
|
2644
3025
|
} else if (isFinite(arrows)) {
|
|
2645
|
-
|
|
3026
|
+
_a3 = x.getOperator(arrows - 1);
|
|
2646
3027
|
b = x.getOperator(arrows - 2);
|
|
2647
|
-
if (b >= 10) ++
|
|
3028
|
+
if (b >= 10) ++_a3;
|
|
2648
3029
|
d = x.getOperatorIndex(arrows);
|
|
2649
3030
|
x.array.splice(1, Math.ceil(d) - 1);
|
|
2650
|
-
x.array[0].repeat =
|
|
3031
|
+
x.array[0].repeat = _a3;
|
|
2651
3032
|
if (Number.isInteger(d)) x.array[1].repeat += c;else x.array.splice(1, 0, newOperator(c, arrows, expans, megota));
|
|
2652
3033
|
} else {
|
|
2653
3034
|
x.array.splice(1, 0, newOperator(c, arrows, expans, megota));
|
|
@@ -2656,10 +3037,10 @@
|
|
|
2656
3037
|
break;
|
|
2657
3038
|
}
|
|
2658
3039
|
}
|
|
2659
|
-
|
|
3040
|
+
_a3 = input.split(/[Ee]/);
|
|
2660
3041
|
b = [x.array[0].repeat, 0];
|
|
2661
3042
|
c = 1;
|
|
2662
|
-
for (var
|
|
3043
|
+
for (var i = _a3.length - 1; i >= 0; --i) {
|
|
2663
3044
|
//The things that are already there
|
|
2664
3045
|
if (b[0] < MSI_LOG10 && b[1] === 0) {
|
|
2665
3046
|
b[0] = Math.pow(10, c * b[0]);
|
|
@@ -2676,12 +3057,12 @@
|
|
|
2676
3057
|
b[1]++;
|
|
2677
3058
|
}
|
|
2678
3059
|
//Multiplying coefficient
|
|
2679
|
-
var decimalPointPos =
|
|
2680
|
-
var intPartLen = decimalPointPos == -1 ?
|
|
3060
|
+
var decimalPointPos = _a3[i].indexOf(".");
|
|
3061
|
+
var intPartLen = decimalPointPos == -1 ? _a3[i].length : decimalPointPos;
|
|
2681
3062
|
if (b[1] === 0) {
|
|
2682
|
-
if (intPartLen >= LONG_STRING_MIN_LENGTH) b[0] = Math.log10(b[0]) + log10LongString(
|
|
3063
|
+
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]);
|
|
2683
3064
|
} else {
|
|
2684
|
-
d = intPartLen >= LONG_STRING_MIN_LENGTH ? log10LongString(
|
|
3065
|
+
d = intPartLen >= LONG_STRING_MIN_LENGTH ? log10LongString(_a3[i].substring(0, intPartLen)) : _a3[i] ? Math.log10(Number(_a3[i])) : 0;
|
|
2685
3066
|
if (b[1] == 1) {
|
|
2686
3067
|
b[0] += d;
|
|
2687
3068
|
} else if (b[1] == 2 && b[0] < MSI_LOG10 + Math.log10(d)) {
|
|
@@ -2712,6 +3093,17 @@
|
|
|
2712
3093
|
key: "fromObject",
|
|
2713
3094
|
value: function fromObject(powlikeObject) {
|
|
2714
3095
|
var obj = new PowiainaNum();
|
|
3096
|
+
obj.resetFromObject({
|
|
3097
|
+
array: [{
|
|
3098
|
+
arrow: 0,
|
|
3099
|
+
expans: 1,
|
|
3100
|
+
megota: 1,
|
|
3101
|
+
repeat: NaN
|
|
3102
|
+
}],
|
|
3103
|
+
small: false,
|
|
3104
|
+
layer: 0,
|
|
3105
|
+
sign: 0
|
|
3106
|
+
});
|
|
2715
3107
|
obj.array = [];
|
|
2716
3108
|
if (isExpantaNumArray(powlikeObject)) {
|
|
2717
3109
|
for (var i = 0; i < powlikeObject.length; i++) {
|
|
@@ -2729,8 +3121,8 @@
|
|
|
2729
3121
|
} else if (isPowiainaNum01XArray(powlikeObject)) {
|
|
2730
3122
|
var arrayobj = powlikeObject;
|
|
2731
3123
|
obj.array[0] = newOperator(arrayobj[0]);
|
|
2732
|
-
for (var
|
|
2733
|
-
var b = arrayobj[
|
|
3124
|
+
for (var _i4 = 1; _i4 < arrayobj.length; _i4++) {
|
|
3125
|
+
var b = arrayobj[_i4];
|
|
2734
3126
|
obj.array[1] = newOperator(b[1], replaceXToInfinity(b[0]), replaceXToInfinity(b[2]), b[3]);
|
|
2735
3127
|
}
|
|
2736
3128
|
obj.small = false;
|
|
@@ -2738,21 +3130,21 @@
|
|
|
2738
3130
|
obj.layer = 0;
|
|
2739
3131
|
return obj;
|
|
2740
3132
|
} else {
|
|
2741
|
-
|
|
2742
|
-
obj.array[_i4] = {
|
|
2743
|
-
arrow: powlikeObject.array[_i4].arrow,
|
|
2744
|
-
expans: powlikeObject.array[_i4].expans,
|
|
2745
|
-
megota: powlikeObject.array[_i4].megota,
|
|
2746
|
-
repeat: powlikeObject.array[_i4].repeat,
|
|
2747
|
-
valuereplaced: powlikeObject.array[_i4].valuereplaced
|
|
2748
|
-
};
|
|
2749
|
-
}
|
|
2750
|
-
obj.small = powlikeObject.small;
|
|
2751
|
-
obj.sign = powlikeObject.sign;
|
|
2752
|
-
obj.layer = powlikeObject.layer;
|
|
3133
|
+
obj.resetFromObject(powlikeObject);
|
|
2753
3134
|
return obj;
|
|
2754
3135
|
}
|
|
2755
3136
|
}
|
|
3137
|
+
}, {
|
|
3138
|
+
key: "grahalFunction",
|
|
3139
|
+
value: function grahalFunction(layers2) {
|
|
3140
|
+
var layers = new PowiainaNum(layers2);
|
|
3141
|
+
if (!layers.isInt() || layers.lt(0) || layers.isNaN()) return PowiainaNum.NaN.clone();
|
|
3142
|
+
if (layers.eq(1)) return new PowiainaNum("10^^^(10^)^7625597484984 3638334640023.7783");else if (layers.lte(MSI)) {
|
|
3143
|
+
return new PowiainaNum("(10{!})^".concat(layers.toNumber(), " 10^^^(10^)^7625597484984 3638334640023.7783"));
|
|
3144
|
+
} else {
|
|
3145
|
+
return PowiainaNum.BEAF(3, layers, 1, 2);
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
2756
3148
|
}]);
|
|
2757
3149
|
}();
|
|
2758
3150
|
_a = Symbol.toStringTag;
|
|
@@ -2969,6 +3361,20 @@
|
|
|
2969
3361
|
PowiainaNum.POW_2_44_MOD_PI = 1.701173079953;
|
|
2970
3362
|
//#endregion
|
|
2971
3363
|
PowiainaNum.arrowFuncMap = new Map();
|
|
3364
|
+
//#region configurations
|
|
3365
|
+
/**
|
|
3366
|
+
* If you set this config to true,
|
|
3367
|
+
* 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.
|
|
3368
|
+
*/
|
|
3369
|
+
PowiainaNum.usingBreakEternityLikeFromString = true;
|
|
3370
|
+
/**
|
|
3371
|
+
* If you set this config to true, the `constructor` method will return Zero instead of NaN when call new PowiainaNum() with no arguments.
|
|
3372
|
+
*/
|
|
3373
|
+
PowiainaNum.blankArgumentConstructorReturnZero = false;
|
|
3374
|
+
/**
|
|
3375
|
+
* If you set this config to true, when calucation returns NaN, the program will throw error.
|
|
3376
|
+
*/
|
|
3377
|
+
PowiainaNum.throwErrorOnResultNaN = false;
|
|
2972
3378
|
|
|
2973
3379
|
exports.arraySortFunction = arraySortFunction;
|
|
2974
3380
|
exports["default"] = PowiainaNum;
|