powiaina_num.js 0.2.0-alpha.3.3 → 0.2.0-alpha.3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/PowiainaNum.cjs.js
CHANGED
|
@@ -1220,9 +1220,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1220
1220
|
}
|
|
1221
1221
|
if (x.array.length > PowiainaNum.maxOps) x.array.splice(1, x.array.length - PowiainaNum.maxOps); // max operators check
|
|
1222
1222
|
// for any 10^a but a >log10(MSI), replace to regular 10^a
|
|
1223
|
-
if (this.
|
|
1224
|
-
this.setOperator(this.
|
|
1225
|
-
this.setOperator(Math.pow(10, this.
|
|
1223
|
+
if (this.array.length >= 2 && this.array[1].arrow == 1 && this.array[1].repeat >= 1 && this.array[0].repeat < MSI_LOG10) {
|
|
1224
|
+
this.setOperator(this.array[1].repeat - 1, 1);
|
|
1225
|
+
this.setOperator(Math.pow(10, this.array[0].repeat), 0);
|
|
1226
1226
|
renormalize = true;
|
|
1227
1227
|
}
|
|
1228
1228
|
if (this.getOperator(0) > MSI && !isFinite(this.getOperator(0))) {
|
|
@@ -1247,7 +1247,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1247
1247
|
x.array[0].repeat = 10;
|
|
1248
1248
|
renormalize = true;
|
|
1249
1249
|
}
|
|
1250
|
-
if (x.array.length >= 2 && x.array[0].repeat < MSI && x.array[1].arrow >= 2 && x.array[1].repeat == 1 &&
|
|
1250
|
+
if (x.array.length >= 2 && x.array[0].repeat < MSI && x.array[1].arrow >= 2 && x.array[1].repeat == 1 &&
|
|
1251
|
+
//10^^^ 10
|
|
1252
|
+
isFinite(x.array[1].arrow)) {
|
|
1251
1253
|
// for any 10{A sample=2}1e9, turn into (10{A-1})^1e9-1 10
|
|
1252
1254
|
// But dont convert when a is infinite
|
|
1253
1255
|
// [1e9, [R=1, A=2, sth, sth]]
|
|
@@ -1274,10 +1276,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1274
1276
|
function getOperatorIndex(arrow) {
|
|
1275
1277
|
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1276
1278
|
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1277
|
-
if (this.array.length == 1 && arrow == 0) return 0;
|
|
1278
|
-
if (this.array.length == 1 && arrow == 1) return 0.5;
|
|
1279
|
-
if (this.array.length == 2 && arrow == 1) return 1;
|
|
1280
|
-
if (this.array.length == 2 && arrow == 0) return 0;
|
|
1281
1279
|
for (var i = 0; i < this.array.length; i++) {
|
|
1282
1280
|
var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
|
|
1283
1281
|
if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
|
|
@@ -1860,7 +1858,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1860
1858
|
obj.small = false;
|
|
1861
1859
|
obj.sign = 1;
|
|
1862
1860
|
obj.layer = 0;
|
|
1863
|
-
obj.normalize();
|
|
1864
1861
|
return obj;
|
|
1865
1862
|
} else {
|
|
1866
1863
|
for (var _i3 = 0; _i3 < powlikeObject.array.length; _i3++) {
|
package/dist/PowiainaNum.esm.js
CHANGED
|
@@ -1218,9 +1218,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1218
1218
|
}
|
|
1219
1219
|
if (x.array.length > PowiainaNum.maxOps) x.array.splice(1, x.array.length - PowiainaNum.maxOps); // max operators check
|
|
1220
1220
|
// for any 10^a but a >log10(MSI), replace to regular 10^a
|
|
1221
|
-
if (this.
|
|
1222
|
-
this.setOperator(this.
|
|
1223
|
-
this.setOperator(Math.pow(10, this.
|
|
1221
|
+
if (this.array.length >= 2 && this.array[1].arrow == 1 && this.array[1].repeat >= 1 && this.array[0].repeat < MSI_LOG10) {
|
|
1222
|
+
this.setOperator(this.array[1].repeat - 1, 1);
|
|
1223
|
+
this.setOperator(Math.pow(10, this.array[0].repeat), 0);
|
|
1224
1224
|
renormalize = true;
|
|
1225
1225
|
}
|
|
1226
1226
|
if (this.getOperator(0) > MSI && !isFinite(this.getOperator(0))) {
|
|
@@ -1245,7 +1245,9 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1245
1245
|
x.array[0].repeat = 10;
|
|
1246
1246
|
renormalize = true;
|
|
1247
1247
|
}
|
|
1248
|
-
if (x.array.length >= 2 && x.array[0].repeat < MSI && x.array[1].arrow >= 2 && x.array[1].repeat == 1 &&
|
|
1248
|
+
if (x.array.length >= 2 && x.array[0].repeat < MSI && x.array[1].arrow >= 2 && x.array[1].repeat == 1 &&
|
|
1249
|
+
//10^^^ 10
|
|
1250
|
+
isFinite(x.array[1].arrow)) {
|
|
1249
1251
|
// for any 10{A sample=2}1e9, turn into (10{A-1})^1e9-1 10
|
|
1250
1252
|
// But dont convert when a is infinite
|
|
1251
1253
|
// [1e9, [R=1, A=2, sth, sth]]
|
|
@@ -1272,10 +1274,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1272
1274
|
function getOperatorIndex(arrow) {
|
|
1273
1275
|
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1274
1276
|
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1275
|
-
if (this.array.length == 1 && arrow == 0) return 0;
|
|
1276
|
-
if (this.array.length == 1 && arrow == 1) return 0.5;
|
|
1277
|
-
if (this.array.length == 2 && arrow == 1) return 1;
|
|
1278
|
-
if (this.array.length == 2 && arrow == 0) return 0;
|
|
1279
1277
|
for (var i = 0; i < this.array.length; i++) {
|
|
1280
1278
|
var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
|
|
1281
1279
|
if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
|
|
@@ -1858,7 +1856,6 @@ var PowiainaNum = /*#__PURE__*/function () {
|
|
|
1858
1856
|
obj.small = false;
|
|
1859
1857
|
obj.sign = 1;
|
|
1860
1858
|
obj.layer = 0;
|
|
1861
|
-
obj.normalize();
|
|
1862
1859
|
return obj;
|
|
1863
1860
|
} else {
|
|
1864
1861
|
for (var _i3 = 0; _i3 < powlikeObject.array.length; _i3++) {
|
package/dist/PowiainaNum.js
CHANGED
|
@@ -1224,9 +1224,9 @@
|
|
|
1224
1224
|
}
|
|
1225
1225
|
if (x.array.length > PowiainaNum.maxOps) x.array.splice(1, x.array.length - PowiainaNum.maxOps); // max operators check
|
|
1226
1226
|
// for any 10^a but a >log10(MSI), replace to regular 10^a
|
|
1227
|
-
if (this.
|
|
1228
|
-
this.setOperator(this.
|
|
1229
|
-
this.setOperator(Math.pow(10, this.
|
|
1227
|
+
if (this.array.length >= 2 && this.array[1].arrow == 1 && this.array[1].repeat >= 1 && this.array[0].repeat < MSI_LOG10) {
|
|
1228
|
+
this.setOperator(this.array[1].repeat - 1, 1);
|
|
1229
|
+
this.setOperator(Math.pow(10, this.array[0].repeat), 0);
|
|
1230
1230
|
renormalize = true;
|
|
1231
1231
|
}
|
|
1232
1232
|
if (this.getOperator(0) > MSI && !isFinite(this.getOperator(0))) {
|
|
@@ -1251,7 +1251,9 @@
|
|
|
1251
1251
|
x.array[0].repeat = 10;
|
|
1252
1252
|
renormalize = true;
|
|
1253
1253
|
}
|
|
1254
|
-
if (x.array.length >= 2 && x.array[0].repeat < MSI && x.array[1].arrow >= 2 && x.array[1].repeat == 1 &&
|
|
1254
|
+
if (x.array.length >= 2 && x.array[0].repeat < MSI && x.array[1].arrow >= 2 && x.array[1].repeat == 1 &&
|
|
1255
|
+
//10^^^ 10
|
|
1256
|
+
isFinite(x.array[1].arrow)) {
|
|
1255
1257
|
// for any 10{A sample=2}1e9, turn into (10{A-1})^1e9-1 10
|
|
1256
1258
|
// But dont convert when a is infinite
|
|
1257
1259
|
// [1e9, [R=1, A=2, sth, sth]]
|
|
@@ -1278,10 +1280,6 @@
|
|
|
1278
1280
|
function getOperatorIndex(arrow) {
|
|
1279
1281
|
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1280
1282
|
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1281
|
-
if (this.array.length == 1 && arrow == 0) return 0;
|
|
1282
|
-
if (this.array.length == 1 && arrow == 1) return 0.5;
|
|
1283
|
-
if (this.array.length == 2 && arrow == 1) return 1;
|
|
1284
|
-
if (this.array.length == 2 && arrow == 0) return 0;
|
|
1285
1283
|
for (var i = 0; i < this.array.length; i++) {
|
|
1286
1284
|
var cmp = compareTuples([this.array[i].megota, this.array[i].expans, this.array[i].arrow], [megota, expans, arrow]);
|
|
1287
1285
|
if (cmp == 0) return i; // I find it was [xx,xxx,*xxx*,xxx]!
|
|
@@ -1864,7 +1862,6 @@
|
|
|
1864
1862
|
obj.small = false;
|
|
1865
1863
|
obj.sign = 1;
|
|
1866
1864
|
obj.layer = 0;
|
|
1867
|
-
obj.normalize();
|
|
1868
1865
|
return obj;
|
|
1869
1866
|
} else {
|
|
1870
1867
|
for (var _i3 = 0; _i3 < powlikeObject.array.length; _i3++) {
|
package/dist/PowiainaNum.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).PowiainaNum=e()}(this,(function(){"use strict";function r(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,a=Array(e);t<e;t++)a[t]=r[t];return a}function e(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,a(n.key),n)}}function t(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(e)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?r(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(r){var e=function(r,e){if("object"!=typeof r||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var a=t.call(r,e||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==typeof e?e:e+""}function n(r){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var i=9007199254740991,o=15.954589770191003,s=1.444667861009766,l=/^(PN)?[\/\-\+]*(Infinity|NaN|(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})|\(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})\)\^[1-9]\d*\x20*)*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/;function u(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{repeat:r,arrow:e,expans:t,megota:a,valuereplaced:e==1/0?0:t==1/0?1:-1}}function h(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];for(var a=0;a<Math.min(e[0].length,e[1].length);a++){var n=e[0][a],i=e[1][a];if(n<i)return-1;if(n>i)return 1}return 0}function g(r){return Math.log10(Number(r.substring(0,17)))+(r.length-17)}var f=.5671432904097838;function c(r){var e,t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!Number.isFinite(r))return r;if(n){if(0===r)return r;if(1===r)return f;e=r<10?0:Math.log(r)-Math.log(Math.log(r))}else{if(0===r)return-1/0;e=r<=-.1?-2:Math.log(-r)-Math.log(-Math.log(-r))}for(var i=0;i<100;++i){if(t=(r*Math.exp(-e)+e*e)/(e+1),Math.abs(t-e)<a*Math.abs(t))return t;e=t}throw Error("Iteration failed to converge: ".concat(r.toString()))}function y(r){return 2==r.length}function p(r){return"number"==typeof r[0]&&"number"==typeof r[1]}function m(r){var e,t,a,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(r.isInfiNaN())return r;if(o){if(r.eq(N.ZERO))return N.ZERO.clone();if(r.eq(N.ONE))return N.fromNumber(f);e=r.log()}else{if(r.eq(N.ZERO))return N.NEGATIVE_INFINITY.clone();e=r.neg().log()}for(var s=0;s<100;++s){if(t=e.neg().exp(),a=e.sub(r.mul(t)),(n=e.sub(a.div(e.add(1).sub(e.add(2).mul(a).div(e.mul(2).add(2)))))).sub(e).abs().lt(n.abs().mul(i)))return n;e=n}throw Error("Iteration failed to converge: ".concat(r.toString()))}var v,N=function(){function r(e){if(function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),this.array=[{arrow:0,expans:1,megota:1,repeat:NaN}],this.small=!1,this.sign=0,this.layer=0,void 0===e);else if("number"==typeof e){var t=r.fromNumber(e);this.resetFromObject(t)}else if("object"==n(e)){var a=r.fromObject(e);this.resetFromObject(a)}else if("string"==typeof e){var i=r.fromString(e);this.resetFromObject(i)}}return function(r,t,a){return t&&e(r.prototype,t),a&&e(r,a),Object.defineProperty(r,"prototype",{writable:!1}),r}(r,[{key:"add",value:function(e){var t,a,n,s,l,h,g=this.clone(),f=new r(e);if(g.eq(r.POSITIVE_INFINITY)&&f.eq(r.NEGATIVE_INFINITY)||g.eq(r.NEGATIVE_INFINITY)&&f.eq(r.POSITIVE_INFINITY))return r.NaN.clone();if(!g.isFinite())return g.clone();if(!f.isFinite())return f.clone();if(g.isZero())return f.clone();if(f.isZero())return g.clone();if(g.sign==-f.sign&&function(){var r=g.abs(),e=f.abs();return r.eq(e)}())return r.ZERO.clone();if(g.abs().lt(i)&&f.abs().lt(i))return r.fromNumber(g.toNumber()+f.toNumber());if(g.abs().lt(r.E_MSI_REC)||g.abs().gt(r.E_MSI)||f.abs().lt(r.E_MSI_REC)||f.abs().gt(r.E_MSI))return g.maxabs(f);if(-1==g.sign)return g.neg().add(f.neg()).neg();g.cmpabs(f)>0?(l=g,h=f):(h=g,l=f);var c=1;if(!(l.small||h.small||(null===(t=l.array[1])||void 0===t?void 0:t.repeat)||(null===(a=h.array[1])||void 0===a?void 0:a.repeat)||l.sign!=h.sign))return new r((l.array[0].repeat+h.array[0].repeat)*l.sign);var y=(l.small?-1:1)*((null===(n=l.array[1])||void 0===n?void 0:n.repeat)?l.array[0].repeat:Math.log10(l.array[0].repeat)),p=(h.small?-1:1)*((null===(s=h.array[1])||void 0===s?void 0:s.repeat)?h.array[0].repeat:Math.log10(h.array[0].repeat));if(y-p>o)return l;var m,v,N=-Math.floor(y),w=0;if((v=l.sign*Math.pow(10,y+N)+h.sign*Math.pow(10,p+N))>0&&(w=Math.log10(v)-N),v<0&&(w=Math.log10(-v)-N,c*=-1),0==v)throw Error("Encounter a calculate error");return(m=new r).sign=1,m.array=w>o||w<-o?[u(w,0),u(1,1)]:[u(Math.pow(10,Math.abs(w)),0)],m.small=w<0,m.sign*=c,m}},{key:"sub",value:function(e){return this.add(new r(e).neg())}},{key:"mul",value:function(e){var t,a=this.clone(),n=new r(e);return a.eq(r.POSITIVE_INFINITY)&&n.eq(r.NEGATIVE_INFINITY)||n.eq(r.POSITIVE_INFINITY)&&a.eq(r.NEGATIVE_INFINITY)?r.NEGATIVE_INFINITY.clone():a.isInfiNaN()&&n.eq(r.ZERO)&&n.isInfiNaN()&&a.eq(r.ZERO)?r.NaN.clone():a.eq(r.NEGATIVE_INFINITY)&&n.eq(r.NEGATIVE_INFINITY)?r.POSITIVE_INFINITY.clone():a.isFinite()?n.isFinite()?a.isZero()||n.isZero()?r.ZERO.clone():((t=a.abs().log10().add(n.abs().log10()).pow10()).sign=a.sign*n.sign,t):n.clone():a.clone()}},{key:"div",value:function(e){var t=new r(e).rec();return this.mul(t)}},{key:"pow10",value:function(){var e,t,a=this.clone();return this.isFinite()?a.isneg()?(a.sign*=-1,a.pow10().rec()):a.lte(308.25471555991675)?r.fromNumber(Math.pow(10,a.toNumber())):a.small?a.lt(r.MSI_REC)?r.ONE:new r(Math.pow(10,Math.pow(a.array[0].repeat,-1))):(a.gt(r.TETRATED_MSI)||(a.setOperator((null!==(t=null===(e=a.array[1])||void 0===e?void 0:e.repeat)&&void 0!==t?t:0)+1,1),a.normalize()),a):this.clone()}},{key:"pow",value:function(e){var t=new r(e);if(!t.isFinite())return t.clone();if(!this.isFinite())return this.clone();if(this.eq(10))return t.pow10();if(this.isneg()){if(!t.isInt())return r.NaN.clone();var a=this.abs().pow(t);return a.sign=function(){var r=t.mod(2).round();return r.eq(0)||r.eq(2)?1:-1}(),a}var n=this.toNumber(),i=t.toNumber(),o=Math.pow(n,i);return isFinite(o)?r.fromNumber(o):this.log10().mul(t).pow10()}},{key:"pow_base",value:function(e){return new r(e).pow(this)}},{key:"root",value:function(e){var t=new r(e);return this.pow(t.rec())}},{key:"sqrt",value:function(){return this.pow(.5)}},{key:"cbrt",value:function(){return this.abs().root(3).mul(this.sign)}},{key:"tetrate",value:function(e){var t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.clone(),o=new r(e),l=new r(a);if(n.isNaN()||o.isNaN()||l.isNaN())return r.NaN.clone();if(l.neq(r.ONE)&&(o=o.add(l.slog(n))),o.isInfi()&&o.sign>0)return n.gte(s)?r.POSITIVE_INFINITY.clone():(t=this.log().neg()).lambertw().div(t);if(o.lte(-2))return r.NaN.clone();if(n.isZero())return o.isZero()?r.NaN.clone():o.gte(i/2)||o.toNumber()%2==0?r.ZERO.clone():r.ONE.clone();if(n.eq(r.ONE))return o.eq(r.ONE.neg())?r.NaN.clone():r.ONE.clone();if(o.eq(r.ONE.neg()))return r.ZERO.clone();if(o.eq(r.ZERO))return r.ONE.clone();if(o.eq(r.ONE))return n;if(o.eq(2))return n.pow(n);if(n.eq(2)){if(o.eq(3))return r.fromNumber(16);if(o.eq(4))return r.fromNumber(65536)}var u=n.max(o);if(u.gt(r.PENTATED_MSI))return u;if(u.gt(r.TETRATED_MSI)||o.gt(i)){if(this.lt(s))return(t=n.ln().neg()).lambertw().div(t);var h=n.slog(10).add(o);return h.setOperator(h.getOperator(2)+1,2),h.normalize(),h}for(var g=o.toNumber(),f=Math.floor(g),c=n.pow(g-f),y=r.NaN,p=0,m=r.E_MSI.clone();0!==f&&c.lt(m)&&p<100;++p)if(f>0){if(c=n.pow(c),y.eq(c)){f=0;break}y=c,--f}else{if(c=c.log(n),y.eq(c)){f=0;break}y=c,++f}return(100==p||this.lt(s))&&(f=0),c.setOperator(c.getOperator(1)+f,1),c.normalize(),c}},{key:"slog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=this.clone(),a=new r(e);if(t.isInfiNaN())return t;if(a.isNaN())return a;if(a.isInfi())return r.ZERO.clone();if(t.isZero())return r.ONE.clone();if(t.eq(r.ONE))return r.ZERO.clone();if(t.eq(a))return r.ONE.clone();if(a.lt(s)){var n=a.tetrate(1/0);if(t.eq(n))return r.POSITIVE_INFINITY.clone();if(t.gt(n))return r.NaN.clone()}if(t.max(a).gt(r.PENTATED_MSI))return t.gt(a)?t:r.ZERO.clone();if(t.max(a).gt(r.TETRATED_MSI)&&t.gt(a))return t.setOperator(t.getOperator(2)-1,2),t.normalize(),t.sub(t.getOperator(1));if(t.lt(r.ZERO.clone()))return a.pow(t).sub(2);var i=0,o=t.getOperator(1)-a.getOperator(1);if(o>3){var l=o-3;i+=l,t.setOperator(t.getOperator(1)-l,1)}for(var u=0;u<100;++u)if(t.lt(r.ZERO))t=r.pow(e,t),--i;else{if(t.lte(1))return new r(i+t.toNumber()-1);++i,t=r.log(t,e)}return t.gt(10)?new r(i):r.NaN.clone()}},{key:"abs",value:function(){var r=this.clone();return r.sign<0&&(r.sign*=-1),r}},{key:"log10",value:function(){if(this.isneg())return r.NaN.clone();if(this.isZero())return r.NEGATIVE_INFINITY.clone();if(this.small){var e=this.clone();return e.small=!e.small,e.log10().neg()}if(1==this.array.length)return new r(Math.log10(this.array[0].repeat));if(this.gte(r.TETRATED_MSI))return this.clone();var t=this.clone();return t.array[1].repeat=t.array[1].repeat-1,t.normalize(),t}},{key:"log",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.E,t=new r(e);return this.log10().div(t.log10())}},{key:"ln",value:function(){return this.log()}},{key:"plog10",value:function(){return this.max(1).log10()}},{key:"plog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.E,t=new r(e);return this.plog10().div(t.plog10())}},{key:"pln",value:function(){return this.plog()}},{key:"exp",value:function(){return this.pow_base(Math.E)}},{key:"mod",value:function(e){var t=new r(e),a=this.div(t);return a.sub(a.floor()).mul(t)}},{key:"factorial",value:function(){return this.abs().lt(i)?this.add(1).gamma():this.abs().lt(r.E_MSI)?r.exp(this.mul(this.log10().sub(1))):r.exp(this)}},{key:"gamma",value:function(){if(this.small)return this.rec();if(this.lte(i)){if(this.lt(24))return r.fromNumber(function(r){if(!isFinite(r))return r;if(r<-50)return r===Math.trunc(r)?Number.NEGATIVE_INFINITY:0;for(var e=1;r<10;)e*=r,++r;var t=.9189385332046727;t+=((r-=1)+.5)*Math.log(r),t-=r;var a=r*r,n=r;return t+=1/(12*n),t-=1/(360*(n*=a)),t+=1/(1260*(n*=a)),t-=1/(1680*(n*=a)),t+=1/(1188*(n*=a)),t-=691/(360360*(n*=a)),t+=7/(1092*(n*=a)),t-=3617/(122400*(n*=a)),Math.exp(t)/e}(this.sign*this.getOperator(0)));var e=this.getOperator(0)-1,t=.9189385332046727;t+=(e+.5)*Math.log(e);var a=e*e,n=e,o=12*n,s=1/o,l=(t-=e)+s;if(l===t)return r.exp(t);if((l=(t=l)-(s=1/(o=360*(n*=a))))===t)return r.exp(t);t=l;var u=1/(o=1260*(n*=a));return t+=u,t-=u=1/(o=1680*(n*=a)),r.exp(t)}return this.gt(i)?r.exp(this.mul(this.log().sub(1))):r.exp(this)}},{key:"lambertw",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.lt(-.3678794411710499)?r.NaN.clone():e?this.abs().lt("1e-300")?new r(this):this.small?r.fromNumber(c(this.toNumber())):this.lt(i)?r.fromNumber(c(this.sign*this.getOperator(0))):this.lt("eee15")?m(this):this.log():1===this.sign?r.NaN.clone():0===this.layer?r.fromNumber(c(this.sign*this.array[0].repeat,1e-10,!1)):1==this.layer?m(this,1e-10,!1):this.neg().rec().lambertw().neg()}},{key:"arrow",value:function(e){var t=this.clone(),a=new r(e);return!a.isInt()||a.lt(r.ZERO)?(console.warn("The arrow is <0 or not a integer, the returned function will return NaN."),function(){return r.NaN.clone()}):a.eq(0)?function(r){return t.mul(r)}:a.eq(1)?function(r){return t.pow(r)}:a.eq(2)?function(r){return t.tetrate(r)}:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=new r(e),s=r.arrowFuncMap.get("".concat(t.toString()," ").concat(a.toString()," ").concat(o.toString()," ").concat(n));if(s)return s.clone();var l=function(){var e;if(t.isNaN()||o.isNaN())return r.NaN.clone();if(o.lt(r.ZERO))return r.NaN.clone();if(t.eq(r.ZERO))return o.eq(r.ONE)?r.ZERO.clone():r.NaN.clone();if(t.eq(r.ONE))return r.ONE.clone();if(o.eq(r.ZERO))return r.ONE.clone();if(o.eq(r.ONE))return t.clone();if(a.gt(r.MSI))return(e=a.clone()).setOperator(e.getOperator(1/0)+1,1/0),e;var s=a.toNumber();if(o.eq(2))return t.arrow(s-1)(t,n+1);if(t.max(o).gt(r.arrowMSI(s+1)))return t.max(o);if(t.gt(r.arrowMSI(s))||o.gt(i)){t.gt(r.arrowMSI(s))?((e=t.clone()).setOperator(e.getOperator(s)-1,s),e.normalize()):e=t.gt(r.arrowMSI(s-1))?new r(t.getOperator(s-1)):r.ZERO;var l=e.add(o);return l.setOperator(l.getOperator(s)+1,s),l.normalize(),l}if(n>=r.maxOps+10)return new r({small:!1,sign:1,layer:0,array:[u(10,0),u(1,s)]});var h=o.toNumber(),g=Math.floor(h),f=a.sub(r.ONE);e=t.arrow(f)(h-g,n+1);for(var c=0,y=r.arrowMSI(s-1);0!==g&&e.lt(y)&&c<100;c++)g>0&&(e=t.arrow(f)(e,n+1),--g);return 100==c&&(g=0),e.setOperator(e.getOperator(s-1)+g,s-1),e.normalize(),e}();return n<r.maxOps+10&&r.arrowFuncMap.set("".concat(t.toString()," ").concat(a.toString()," ").concat(o.toString()," ").concat(n),l.clone()),l}}},{key:"chain",value:function(r,e){return this.arrow(e)(r)}},{key:"max",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.max.apply(r,[this].concat(t))}},{key:"min",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.min.apply(r,[this].concat(t))}},{key:"maxabs",value:function(){for(var e=arguments.length,a=new Array(e),n=0;n<e;n++)a[n]=arguments[n];var i=a.map((function(e){return new r(e).abs()}));return r.max.apply(r,[this.abs()].concat(t(i)))}},{key:"minabs",value:function(){for(var e=arguments.length,a=new Array(e),n=0;n<e;n++)a[n]=arguments[n];var i=a.map((function(e){return new r(e).abs()}));return r.min.apply(r,[this.abs()].concat(t(i)))}},{key:"cmpabs",value:function(e){var t=new r(e).abs();return this.abs().cmp(t)}},{key:"neg",value:function(){var r=this.clone();return r.sign*=-1,r.normalize(),r}},{key:"rec",value:function(){var r=this.clone();return r.small=!r.small,r}},{key:"floor",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?r.ZERO.clone():r.ONE.neg().clone();var e=this.abs();return e.array[0].repeat=Math[1==this.sign?"floor":"ceil"](e.getOperator(0)),e}},{key:"ceil",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?r.ONE.clone():r.ZERO.clone();var e=this.abs();return e.array[0].repeat=Math[1==this.sign?"ceil":"floor"](e.getOperator(0)),e.sign=this.sign,e}},{key:"round",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?this.rec().lte(2)?r.ONE.clone():r.ZERO.clone():this.abs().rec().lte(2)?r.ZERO.clone():r.ONE.neg().clone();var e=this.abs();return e.array[0].repeat=Math.round(e.array[0].repeat),e.sign=this.sign,e}},{key:"trunc",value:function(){var r=this.clone();return r.gte(0)?r.floor():r.ceil()}},{key:"compare",value:function(e){var t=new r(e);if(this.isNaN()||t.isNaN())return 2;if(this.sign<t.sign)return-1;if(this.sign>t.sign)return 1;var a=-1==this.sign&&-1==t.sign;if(this.small&&!t.small)return-1*(a?-1:1);if(t.small&&!this.small)return 1*(a?-1:1);var n=1;this.small&&t.small&&(n*=-1),a&&(n*=-1);for(var i=0,o=0;this.array.length-1-o>=0&&t.array.length-1-o>=0;o++){var s=this.array[this.array.length-1-o],l=t.array[t.array.length-1-o],u=h([s.megota,s.expans,s.arrow,s.repeat],[l.megota,l.expans,l.arrow,l.repeat]);if(1==u){i=1;break}if(-1==u){i=-1;break}}return i*n+1-1}},{key:"cmp",value:function(r){return this.compare(r)}},{key:"eq",value:function(r){return 0===this.cmp(r)}},{key:"neq",value:function(r){return 0!==this.cmp(r)}},{key:"lt",value:function(r){return-1===this.cmp(r)}},{key:"lte",value:function(r){return this.cmp(r)<=0}},{key:"gt",value:function(r){return 1==this.cmp(r)}},{key:"gte",value:function(r){var e=this.cmp(r);return 0==e||1==e}},{key:"isNaN",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return isNaN(this.getOperator(0))}))},{key:"isZero",value:function(){return Boolean(this.small&&!isFinite(this.getOperator(0)))}},{key:"isFinite",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return Boolean(this.small||isFinite(this.getOperator(0)))&&!this.isNaN()}))},{key:"isInfi",value:function(){return this.rec().isZero()}},{key:"isInfiNaN",value:function(){return this.isInfi()||this.isNaN()}},{key:"isInt",value:function(){return!!this.isZero()||(!(this.small||!Number.isInteger(this.getOperator(0)))||!!this.abs().gte(i/2))}},{key:"ispos",value:function(){return this.sign>0}},{key:"isneg",value:function(){return this.sign<0}},{key:"normalize",value:function(){for(var e=!0,t=this,a=0;a<this.array.length;a++)if(this.array[a].repeat==1/0)return this.array=[{arrow:0,expans:1,megota:1,repeat:1/0}],this.layer=0,this;for(var n=1;n<t.array.length;++n){var s=t.array[n];if(null!==s.arrow&&void 0!==s.arrow||(s.arrow=0),null!==s.expans&&void 0!==s.expans||(s.expans=1),null!==s.megota&&void 0!==s.megota||(s.megota=1),isNaN(s.arrow)||isNaN(s.repeat)||isNaN(s.expans)||isNaN(s.megota))return t.array=[u(NaN,0,1,1)],t;if(!isFinite(s.repeat)||!isFinite(s.megota))return t.array=[u(1/0,0,1,1)],t;Number.isInteger(s.arrow)||(s.arrow=Math.floor(s.arrow)),Number.isInteger(s.repeat)||(s.repeat=Math.floor(s.repeat)),Number.isInteger(s.expans)||(s.expans=Math.floor(s.expans)),Number.isInteger(s.megota)||(s.megota=Math.floor(s.megota))}t.array.length||(t.small=!t.small,t.array=[u(1/0)]);do{for(e=!1,this.array.sort((function(r,e){return h([r.megota,r.expans,r.arrow],[e.megota,e.expans,e.arrow])})),n=1;n<t.array.length-1;++n)t.array[n].arrow==t.array[n+1].arrow&&t.array[n].expans==t.array[n+1].expans&&t.array[n].megota==t.array[n+1].megota&&(t.array[n].repeat+=t.array[n+1].repeat,t.array.splice(n+1,1),--n,e=!0);for(n=1;n<t.array.length;++n)0===t.array[n].arrow||0!==t.array[n].repeat&&null!==t.array[n].repeat&&void 0!==t.array[n].repeat?0==t.array[n].arrow&&t.array[n].expans>=2&&(t.array[n].arrow=1/0,t.array[n].valuereplaced=0,t.array[n].expans=t.array[n].expans-1):(t.array.splice(n,1),--n);for(t.array.length>r.maxOps&&t.array.splice(1,t.array.length-r.maxOps),this.getOperator(1)>=1&&this.getOperator(0)<o&&(this.setOperator(this.getOperator(1)-1,1),this.setOperator(Math.pow(10,this.getOperator(0)),0),e=!0),this.getOperator(0)>i&&!isFinite(this.getOperator(0))&&(this.setOperator(this.getOperator(1)+1,1),this.setOperator(Math.log10(this.getOperator(0)),0),e=!0),1==this.array.length&&this.array[0].repeat<1&&(this.array[0].repeat=1/this.array[0].repeat,this.small=!this.small,e=!0);t.array.length>=2&&1==t.array[0].repeat&&t.array[1].repeat;)t.array[1].repeat>1?t.array[1].repeat--:t.array.splice(1,1),t.array[0].repeat=10,e=!0;t.array.length>=2&&t.array[0].repeat<i&&t.array[1].arrow>=2&&1==t.array[1].repeat&&isFinite(t.array[1].arrow)&&(t.array.splice(1,1,u(t.array[0].repeat,t.array[1].arrow-1,t.array[1].expans,t.array[1].megota)),t.array[0].repeat=10,e=!0),t.array.length>=2&&t.array[1].repeat>i&&(t.array[1].arrow++,t.array[0].repeat=t.array[1].repeat,t.array[1].repeat=1,e=!0)}while(e);return this}},{key:"getOperatorIndex",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(1==this.array.length&&0==r)return 0;if(1==this.array.length&&1==r)return.5;if(2==this.array.length&&1==r)return 1;if(2==this.array.length&&0==r)return 0;for(var a=0;a<this.array.length;a++){var n=h([this.array[a].megota,this.array[a].expans,this.array[a].arrow],[t,e,r]);if(0==n)return a;if(1==n)return a-.5}return this.array.length-.5}},{key:"getOperator",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=this.getOperatorIndex(r,e,t);return this.array[a]?this.array[a].repeat:0}},{key:"setOperator",value:function(r,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=this.getOperatorIndex(e,t,a);return this.array[n]?(this.array[n].repeat=r,!1):(this.array.splice(Math.ceil(n),0,{arrow:e,expans:t,megota:a,valuereplaced:t===1/0?1:e==1/0?0:-1,repeat:r}),!0)}},{key:"clone",value:function(){var e=new r;return e.resetFromObject(this),e}},{key:"resetFromObject",value:function(r){this.array=[];for(var e=0;e<r.array.length;e++)this.array[e]={arrow:r.array[e].arrow,expans:r.array[e].expans,megota:r.array[e].megota,repeat:r.array[e].repeat,valuereplaced:r.array[e].valuereplaced};return this.small=r.small,this.sign=r.sign,this.layer=r.layer,this}},{key:"toNumber",value:function(){return-1==this.sign?-this.neg().toNumber():this.small?1/this.rec().toNumber():this.array.length>2?1/0:1==this.array.length?this.array[0].repeat:2==this.array.length&&1==this.array[1].arrow&&1==this.array[1].expans&&1==this.array[1].megota&&1==this.array[1].repeat?Math.pow(10,this.getOperator(0)):NaN}},{key:"toString",value:function(){if(this.isNaN())return"NaN";if(-1==this.sign)return"-".concat(this.neg().toString());if(this.small)return this.isZero()?"0":"/".concat(this.rec().toString());if(this.isInfi())return"Infinity";for(var r="",e=this.array.length-1;e>=0;e--){var t=this.array[e],a="10{".concat(t.arrow===1/0?"!":t.arrow).concat(t.expans>1||t.megota>1?",".concat(t.expans===1/0?"!":t.expans):"").concat(t.megota>1?",".concat(t.megota):"","}");a=1==t.arrow&&1==t.expans&&1==t.megota&&t.repeat<5?"e".repeat(t.repeat):0==t.arrow&&1==t.expans&&1==t.megota?t.repeat.toString():t.repeat>1?"(".concat(a,")^").concat(t.repeat," "):"".concat(a),r+="".concat(a)}return r}},{key:"toJSON",value:function(){return"PN"+this.toString()}},{key:"arr01",get:function(){for(var r=[0],e=0;e<this.array.length;e++)0==e?r[0]=this.array[e].repeat:(r[e]=[0,0,0,0],r[e][0]=this.array[e].arrow==1/0?"x":this.array[e].arrow,r[e][1]=this.array[e].repeat,r[e][2]=this.array[e].expans==1/0?"x":this.array[e].expans,r[e][3]=this.array[e].megota);return r}}],[{key:"add",value:function(e,t){return new r(e).add(t)}},{key:"sub",value:function(e,t){return new r(e).sub(t)}},{key:"mul",value:function(e,t){return new r(e).mul(t)}},{key:"div",value:function(e,t){return new r(e).div(t)}},{key:"pow",value:function(e,t){return new r(e).pow(t)}},{key:"root",value:function(e,t){return new r(e).root(t)}},{key:"sqrt",value:function(e){return new r(e).sqrt()}},{key:"cbrt",value:function(e){return new r(e).cbrt()}},{key:"tetrate",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return new r(e).tetrate(t,a)}},{key:"log10",value:function(e){return new r(e).log10()}},{key:"log",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new r(e).log(t)}},{key:"plog10",value:function(e){return new r(e).plog10()}},{key:"plog",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new r(e).plog(t)}},{key:"exp",value:function(e){return new r(e).pow_base(Math.E)}},{key:"factorial",value:function(e){return new r(e).factorial()}},{key:"gamma",value:function(e){return new r(e).gamma()}},{key:"lambertw",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new r(e).lambertw(t)}},{key:"tetrate_10",value:function(e){return r.fromNumber(10).tetrate(e)}},{key:"max",value:function(){for(var e=r.NEGATIVE_INFINITY,t=arguments.length,a=new Array(t),n=0;n<t;n++)a[n]=arguments[n];for(var i=0;i<a.length;i++)e.lt(a[i])&&(e=new r(a[i]).clone());return e}},{key:"min",value:function(){for(var e=r.POSITIVE_INFINITY,t=arguments.length,a=new Array(t),n=0;n<t;n++)a[n]=arguments[n];for(var i=0;i<a.length;i++)e.gt(a[i])&&(e=new r(a[i]).clone());return e}},{key:"clampMin",value:function(){return r.max.apply(r,arguments)}},{key:"clampMax",value:function(){return r.min.apply(r,arguments)}},{key:"sign",value:function(e){return new r(e).sign}},{key:"isNaN",value:function(e){return new r(e).isNaN()}},{key:"arrowMSI",value:function(e){return new r("10{".concat(e,"}").concat(i))}},{key:"fromNumber",value:function(e){var t=new r;if(e<0)t.sign=-1;else{if(0==e)return t.sign=0,t.small=!0,t.array=[u(1/0,0)],t;e>0&&(t.sign=1)}var a=Math.abs(e);return a>=11102230246251568e-32&&a<1?(t.small=!0,t.array=[u(1/a,0)]):a<11102230246251568e-32?(t.small=!0,t.array=[u(-Math.log10(a),0),u(1,1)]):a<=i?t.array=[u(a,0)]:(t.setOperator(Math.log10(a),0),t.array=[u(Math.log10(a),0),u(1,1)]),t}},{key:"fromString",value:function(e){var t,a,n,s,h,f,c,y=new r;if(e.startsWith("PN")&&(e=e.substring(2)),!isNaN(Number(e))){var p=Number(e),m=!1;if(0==p?/^(0*\.0*e)|(0*\.0*)$/.test(e)&&(m=!0):m=!0,!m){var v=e.search(/e/),N=e.substring((-1==v?e.length:v)+1),w=e.substring(0,-1==v?void 0:v),b=[0,0];if(b[1]=Number(N||"0"),Number(w)>=1){var I=w.length>=17?g(w):Math.log10(Number(w)),d=I-(Math.floor(I)-1);b[0]=Math.pow(10,d),b[1]+=d}else{var O=(c=w.match(/^0\.(0*)[1-9]/))?c[1].length:0;w=(w=w.substring(w.search(/[1-9]/))).charAt(0)+"."+w.substring(1),O+=1,b[0]=Number(w),b[1]+=-O}return r.pow(10,-b[1]-1).mul(10*Math.pow(b[0],-1)).rec()}if(isFinite(p)&&m)return y.resetFromObject(r.fromNumber(Number(e))),y}if(e=e.replace(/\(e\^(\d+)\)/g,"(10^)^$1 ").replace(/(\d+)\x20*PT/g,"(10^)^$1 "),!l.test(e))throw"[PowiainaNum 0.2 error]malformed input: "+e;var E=!1,M=!1;if("-"==e[0]||"+"==e[0]){var k=e.search(/[^-\+]/);E=(null!==(a=null===(t=e.substring(0,k).match(/-/g))||void 0===t?void 0:t.length)&&void 0!==a?a:0)%2==1,e=e.substring(k)}if("/"==e[0]){k=e.search(/[^\/]/);M=(null!==(s=null===(n=e.substring(0,k).match(/\//g))||void 0===n?void 0:n.length)&&void 0!==s?s:0)%2==1,e=e.substring(k)}if("NaN"==e)y.array=[u(NaN)];else if("Infinity"==e)y.array=[u(1/0)];else{var x,T,S,_;for(y.sign=1,y.array=[u(0)];e&&/^(\(?10[\^\{])/.test(e);){var F,q,R;if("("==e[0]&&(e=e.substring(1)),"^"==e[2])F=x=e.substring(2).search(/[^\^]/),T=x+2;else{x=e.indexOf("}");var A=e.substring(3,x).split(",");F=Number("!"==A[0]?1/0:A[0]),q=Number(null!==(h="!"==A[1]?1/0:A[1])&&void 0!==h?h:1),R=Number(null!==(f=A[2])&&void 0!==f?f:1),T=x+1}")"==(e=e.substring(T))[0]?(x=e.indexOf(" "),S=Number(e.substring(2,x)),e=e.substring(x+1)):S=1,1==F&&1==q&&1==R?y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat+=S:y.array.splice(1,0,u(S,1,q,R)):2==F&&1==q&&1==R?(x=y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat:0,(T=y.array[0].repeat)>=1e10&&++x,T>=10&&++x,y.array[0].repeat=x,y.array.length>=2&&1==y.array[1].arrow&&y.array.splice(1,1),_=y.getOperatorIndex(2),Number.isInteger(_)?y.array[_].repeat+=S:y.array.splice(Math.ceil(_),0,u(S,2,q,R))):isFinite(F)?(x=y.getOperator(F-1),(T=y.getOperator(F-2))>=10&&++x,_=y.getOperatorIndex(F),y.array.splice(1,Math.ceil(_)-1),y.array[0].repeat=x,Number.isInteger(_)?y.array[1].repeat+=S:y.array.splice(1,0,u(S,F,q,R))):y.array.splice(1,0,u(S,F,q,R))}x=e.split(/[Ee]/),T=[y.array[0].repeat,0],S=1;for(var Z=x.length-1;Z>=0;--Z){T[0]<o&&0===T[1]?T[0]=Math.pow(10,S*T[0]):-1==S?(0===T[1]?T[0]=Math.pow(10,S*T[0]):1==T[1]&&T[0]<=Math.log10(Number.MAX_VALUE)?T[0]=Math.pow(10,S*Math.pow(10,T[0])):T[0]=0,T[1]=0):T[1]++;var P=x[Z].indexOf("."),V=-1==P?x[Z].length:P;0===T[1]?V>=17?(T[0]=Math.log10(T[0])+g(x[Z].substring(0,V)),T[1]=1):x[Z]&&(T[0]*=Number(x[Z])):(_=V>=17?g(x[Z].substring(0,V)):x[Z]?Math.log10(Number(x[Z])):0,1==T[1]?T[0]+=_:2==T[1]&&T[0]<o+Math.log10(_)&&(T[0]+=Math.log10(1+Math.pow(10,Math.log10(_)-T[0])))),T[0]<o&&T[1]?(T[0]=Math.pow(10,T[0]),T[1]--):T[0]>i&&(T[0]=Math.log10(T[0]),T[1]++)}y.array[0].repeat=T[0],T[1]&&(y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat+=T[1]:y.array.splice(1,0,u(T[1],1,1,1)))}return E&&(y.sign*=-1),M&&(y.small=!y.small),y.normalize(),y.normalize(),y}},{key:"fromObject",value:function(e){var t=new r;if(t.array=[],function(r){if(!Array.isArray(r))return!1;for(var e=0;e<r.length;e++){var t=r[e];if(!Array.isArray(t))return!1;if(!y(t))return!1;if(!p(t))return!1}return!0}(e)){for(var a=0;a<e.length;a++)t.array[a]={arrow:e[a][0],expans:1,megota:1,repeat:e[a][1]};return t.small=!1,t.sign=1,t.layer=0,t.normalize(),t}for(var n=0;n<e.array.length;n++)t.array[n]={arrow:e.array[n].arrow,expans:e.array[n].expans,megota:e.array[n].megota,repeat:e.array[n].repeat,valuereplaced:e.array[n].valuereplaced};return t.small=e.small,t.sign=e.sign,t.layer=e.layer,t}}])}();return N.ZERO=new N({array:[{arrow:0,expans:1,megota:1,repeat:1/0}],small:!0,layer:0,sign:0}),N.ONE=new N({array:[{arrow:0,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),N.MSI=new N(i),N.MSI_REC=((v=new N(i)).small=!0,v),N.E_MSI=new N({array:[{arrow:0,expans:1,megota:1,repeat:i},{arrow:1,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),N.E_MSI_REC=new N({array:[{arrow:0,expans:1,megota:1,repeat:i},{arrow:1,expans:1,megota:1,repeat:1}],small:!0,layer:0,sign:1}),N.TETRATED_MSI=new N({array:[{arrow:0,expans:1,megota:1,repeat:1e10},{arrow:1,expans:1,megota:1,repeat:i-2}],small:!1,layer:0,sign:1}),N.PENTATED_MSI=new N({array:[{arrow:0,expans:1,megota:1,repeat:10},{arrow:2,expans:1,megota:1,repeat:i-1}],small:!1,layer:0,sign:1}),N.TRITRI=new N({small:!1,layer:0,sign:1,array:[u(3638334640023.7783,0,1,1),u(7625587484984,1,1,1)]}),N.GRAHAMS_NUMBER=new N("(10{!})^63 10^^^(10^)^7625597484984 3638334640023.7783"),N.POSITIVE_INFINITY=new N(1/0),N.NEGATIVE_INFINITY=new N(-1/0),N.NaN=new N({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),N.E=new N(Math.E),N.LN2=new N(Math.LN2),N.LN10=new N(Math.LN10),N.LOG2E=new N(Math.LOG2E),N.LOG10E=new N(Math.LOG10E),N.PI=new N(Math.PI),N.SQRT1_2=new N(Math.SQRT1_2),N.SQRT2=new N(Math.SQRT2),N.maxOps=100,N.arrowFuncMap=new Map,N}));
|
|
1
|
+
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).PowiainaNum=e()}(this,(function(){"use strict";function r(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,a=Array(e);t<e;t++)a[t]=r[t];return a}function e(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,a(n.key),n)}}function t(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(e)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?r(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(r){var e=function(r,e){if("object"!=typeof r||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var a=t.call(r,e||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==typeof e?e:e+""}function n(r){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var i=9007199254740991,o=15.954589770191003,s=1.444667861009766,l=/^(PN)?[\/\-\+]*(Infinity|NaN|(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})|\(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})\)\^[1-9]\d*\x20*)*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/;function u(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{repeat:r,arrow:e,expans:t,megota:a,valuereplaced:e==1/0?0:t==1/0?1:-1}}function h(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];for(var a=0;a<Math.min(e[0].length,e[1].length);a++){var n=e[0][a],i=e[1][a];if(n<i)return-1;if(n>i)return 1}return 0}function f(r){return Math.log10(Number(r.substring(0,17)))+(r.length-17)}var g=.5671432904097838;function c(r){var e,t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!Number.isFinite(r))return r;if(n){if(0===r)return r;if(1===r)return g;e=r<10?0:Math.log(r)-Math.log(Math.log(r))}else{if(0===r)return-1/0;e=r<=-.1?-2:Math.log(-r)-Math.log(-Math.log(-r))}for(var i=0;i<100;++i){if(t=(r*Math.exp(-e)+e*e)/(e+1),Math.abs(t-e)<a*Math.abs(t))return t;e=t}throw Error("Iteration failed to converge: ".concat(r.toString()))}function y(r){return 2==r.length}function p(r){return"number"==typeof r[0]&&"number"==typeof r[1]}function m(r){var e,t,a,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(r.isInfiNaN())return r;if(o){if(r.eq(N.ZERO))return N.ZERO.clone();if(r.eq(N.ONE))return N.fromNumber(g);e=r.log()}else{if(r.eq(N.ZERO))return N.NEGATIVE_INFINITY.clone();e=r.neg().log()}for(var s=0;s<100;++s){if(t=e.neg().exp(),a=e.sub(r.mul(t)),(n=e.sub(a.div(e.add(1).sub(e.add(2).mul(a).div(e.mul(2).add(2)))))).sub(e).abs().lt(n.abs().mul(i)))return n;e=n}throw Error("Iteration failed to converge: ".concat(r.toString()))}var v,N=function(){function r(e){if(function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),this.array=[{arrow:0,expans:1,megota:1,repeat:NaN}],this.small=!1,this.sign=0,this.layer=0,void 0===e);else if("number"==typeof e){var t=r.fromNumber(e);this.resetFromObject(t)}else if("object"==n(e)){var a=r.fromObject(e);this.resetFromObject(a)}else if("string"==typeof e){var i=r.fromString(e);this.resetFromObject(i)}}return function(r,t,a){return t&&e(r.prototype,t),a&&e(r,a),Object.defineProperty(r,"prototype",{writable:!1}),r}(r,[{key:"add",value:function(e){var t,a,n,s,l,h,f=this.clone(),g=new r(e);if(f.eq(r.POSITIVE_INFINITY)&&g.eq(r.NEGATIVE_INFINITY)||f.eq(r.NEGATIVE_INFINITY)&&g.eq(r.POSITIVE_INFINITY))return r.NaN.clone();if(!f.isFinite())return f.clone();if(!g.isFinite())return g.clone();if(f.isZero())return g.clone();if(g.isZero())return f.clone();if(f.sign==-g.sign&&function(){var r=f.abs(),e=g.abs();return r.eq(e)}())return r.ZERO.clone();if(f.abs().lt(i)&&g.abs().lt(i))return r.fromNumber(f.toNumber()+g.toNumber());if(f.abs().lt(r.E_MSI_REC)||f.abs().gt(r.E_MSI)||g.abs().lt(r.E_MSI_REC)||g.abs().gt(r.E_MSI))return f.maxabs(g);if(-1==f.sign)return f.neg().add(g.neg()).neg();f.cmpabs(g)>0?(l=f,h=g):(h=f,l=g);var c=1;if(!(l.small||h.small||(null===(t=l.array[1])||void 0===t?void 0:t.repeat)||(null===(a=h.array[1])||void 0===a?void 0:a.repeat)||l.sign!=h.sign))return new r((l.array[0].repeat+h.array[0].repeat)*l.sign);var y=(l.small?-1:1)*((null===(n=l.array[1])||void 0===n?void 0:n.repeat)?l.array[0].repeat:Math.log10(l.array[0].repeat)),p=(h.small?-1:1)*((null===(s=h.array[1])||void 0===s?void 0:s.repeat)?h.array[0].repeat:Math.log10(h.array[0].repeat));if(y-p>o)return l;var m,v,N=-Math.floor(y),w=0;if((v=l.sign*Math.pow(10,y+N)+h.sign*Math.pow(10,p+N))>0&&(w=Math.log10(v)-N),v<0&&(w=Math.log10(-v)-N,c*=-1),0==v)throw Error("Encounter a calculate error");return(m=new r).sign=1,m.array=w>o||w<-o?[u(w,0),u(1,1)]:[u(Math.pow(10,Math.abs(w)),0)],m.small=w<0,m.sign*=c,m}},{key:"sub",value:function(e){return this.add(new r(e).neg())}},{key:"mul",value:function(e){var t,a=this.clone(),n=new r(e);return a.eq(r.POSITIVE_INFINITY)&&n.eq(r.NEGATIVE_INFINITY)||n.eq(r.POSITIVE_INFINITY)&&a.eq(r.NEGATIVE_INFINITY)?r.NEGATIVE_INFINITY.clone():a.isInfiNaN()&&n.eq(r.ZERO)&&n.isInfiNaN()&&a.eq(r.ZERO)?r.NaN.clone():a.eq(r.NEGATIVE_INFINITY)&&n.eq(r.NEGATIVE_INFINITY)?r.POSITIVE_INFINITY.clone():a.isFinite()?n.isFinite()?a.isZero()||n.isZero()?r.ZERO.clone():((t=a.abs().log10().add(n.abs().log10()).pow10()).sign=a.sign*n.sign,t):n.clone():a.clone()}},{key:"div",value:function(e){var t=new r(e).rec();return this.mul(t)}},{key:"pow10",value:function(){var e,t,a=this.clone();return this.isFinite()?a.isneg()?(a.sign*=-1,a.pow10().rec()):a.lte(308.25471555991675)?r.fromNumber(Math.pow(10,a.toNumber())):a.small?a.lt(r.MSI_REC)?r.ONE:new r(Math.pow(10,Math.pow(a.array[0].repeat,-1))):(a.gt(r.TETRATED_MSI)||(a.setOperator((null!==(t=null===(e=a.array[1])||void 0===e?void 0:e.repeat)&&void 0!==t?t:0)+1,1),a.normalize()),a):this.clone()}},{key:"pow",value:function(e){var t=new r(e);if(!t.isFinite())return t.clone();if(!this.isFinite())return this.clone();if(this.eq(10))return t.pow10();if(this.isneg()){if(!t.isInt())return r.NaN.clone();var a=this.abs().pow(t);return a.sign=function(){var r=t.mod(2).round();return r.eq(0)||r.eq(2)?1:-1}(),a}var n=this.toNumber(),i=t.toNumber(),o=Math.pow(n,i);return isFinite(o)?r.fromNumber(o):this.log10().mul(t).pow10()}},{key:"pow_base",value:function(e){return new r(e).pow(this)}},{key:"root",value:function(e){var t=new r(e);return this.pow(t.rec())}},{key:"sqrt",value:function(){return this.pow(.5)}},{key:"cbrt",value:function(){return this.abs().root(3).mul(this.sign)}},{key:"tetrate",value:function(e){var t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.clone(),o=new r(e),l=new r(a);if(n.isNaN()||o.isNaN()||l.isNaN())return r.NaN.clone();if(l.neq(r.ONE)&&(o=o.add(l.slog(n))),o.isInfi()&&o.sign>0)return n.gte(s)?r.POSITIVE_INFINITY.clone():(t=this.log().neg()).lambertw().div(t);if(o.lte(-2))return r.NaN.clone();if(n.isZero())return o.isZero()?r.NaN.clone():o.gte(i/2)||o.toNumber()%2==0?r.ZERO.clone():r.ONE.clone();if(n.eq(r.ONE))return o.eq(r.ONE.neg())?r.NaN.clone():r.ONE.clone();if(o.eq(r.ONE.neg()))return r.ZERO.clone();if(o.eq(r.ZERO))return r.ONE.clone();if(o.eq(r.ONE))return n;if(o.eq(2))return n.pow(n);if(n.eq(2)){if(o.eq(3))return r.fromNumber(16);if(o.eq(4))return r.fromNumber(65536)}var u=n.max(o);if(u.gt(r.PENTATED_MSI))return u;if(u.gt(r.TETRATED_MSI)||o.gt(i)){if(this.lt(s))return(t=n.ln().neg()).lambertw().div(t);var h=n.slog(10).add(o);return h.setOperator(h.getOperator(2)+1,2),h.normalize(),h}for(var f=o.toNumber(),g=Math.floor(f),c=n.pow(f-g),y=r.NaN,p=0,m=r.E_MSI.clone();0!==g&&c.lt(m)&&p<100;++p)if(g>0){if(c=n.pow(c),y.eq(c)){g=0;break}y=c,--g}else{if(c=c.log(n),y.eq(c)){g=0;break}y=c,++g}return(100==p||this.lt(s))&&(g=0),c.setOperator(c.getOperator(1)+g,1),c.normalize(),c}},{key:"slog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=this.clone(),a=new r(e);if(t.isInfiNaN())return t;if(a.isNaN())return a;if(a.isInfi())return r.ZERO.clone();if(t.isZero())return r.ONE.clone();if(t.eq(r.ONE))return r.ZERO.clone();if(t.eq(a))return r.ONE.clone();if(a.lt(s)){var n=a.tetrate(1/0);if(t.eq(n))return r.POSITIVE_INFINITY.clone();if(t.gt(n))return r.NaN.clone()}if(t.max(a).gt(r.PENTATED_MSI))return t.gt(a)?t:r.ZERO.clone();if(t.max(a).gt(r.TETRATED_MSI)&&t.gt(a))return t.setOperator(t.getOperator(2)-1,2),t.normalize(),t.sub(t.getOperator(1));if(t.lt(r.ZERO.clone()))return a.pow(t).sub(2);var i=0,o=t.getOperator(1)-a.getOperator(1);if(o>3){var l=o-3;i+=l,t.setOperator(t.getOperator(1)-l,1)}for(var u=0;u<100;++u)if(t.lt(r.ZERO))t=r.pow(e,t),--i;else{if(t.lte(1))return new r(i+t.toNumber()-1);++i,t=r.log(t,e)}return t.gt(10)?new r(i):r.NaN.clone()}},{key:"abs",value:function(){var r=this.clone();return r.sign<0&&(r.sign*=-1),r}},{key:"log10",value:function(){if(this.isneg())return r.NaN.clone();if(this.isZero())return r.NEGATIVE_INFINITY.clone();if(this.small){var e=this.clone();return e.small=!e.small,e.log10().neg()}if(1==this.array.length)return new r(Math.log10(this.array[0].repeat));if(this.gte(r.TETRATED_MSI))return this.clone();var t=this.clone();return t.array[1].repeat=t.array[1].repeat-1,t.normalize(),t}},{key:"log",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.E,t=new r(e);return this.log10().div(t.log10())}},{key:"ln",value:function(){return this.log()}},{key:"plog10",value:function(){return this.max(1).log10()}},{key:"plog",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.E,t=new r(e);return this.plog10().div(t.plog10())}},{key:"pln",value:function(){return this.plog()}},{key:"exp",value:function(){return this.pow_base(Math.E)}},{key:"mod",value:function(e){var t=new r(e),a=this.div(t);return a.sub(a.floor()).mul(t)}},{key:"factorial",value:function(){return this.abs().lt(i)?this.add(1).gamma():this.abs().lt(r.E_MSI)?r.exp(this.mul(this.log10().sub(1))):r.exp(this)}},{key:"gamma",value:function(){if(this.small)return this.rec();if(this.lte(i)){if(this.lt(24))return r.fromNumber(function(r){if(!isFinite(r))return r;if(r<-50)return r===Math.trunc(r)?Number.NEGATIVE_INFINITY:0;for(var e=1;r<10;)e*=r,++r;var t=.9189385332046727;t+=((r-=1)+.5)*Math.log(r),t-=r;var a=r*r,n=r;return t+=1/(12*n),t-=1/(360*(n*=a)),t+=1/(1260*(n*=a)),t-=1/(1680*(n*=a)),t+=1/(1188*(n*=a)),t-=691/(360360*(n*=a)),t+=7/(1092*(n*=a)),t-=3617/(122400*(n*=a)),Math.exp(t)/e}(this.sign*this.getOperator(0)));var e=this.getOperator(0)-1,t=.9189385332046727;t+=(e+.5)*Math.log(e);var a=e*e,n=e,o=12*n,s=1/o,l=(t-=e)+s;if(l===t)return r.exp(t);if((l=(t=l)-(s=1/(o=360*(n*=a))))===t)return r.exp(t);t=l;var u=1/(o=1260*(n*=a));return t+=u,t-=u=1/(o=1680*(n*=a)),r.exp(t)}return this.gt(i)?r.exp(this.mul(this.log().sub(1))):r.exp(this)}},{key:"lambertw",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.lt(-.3678794411710499)?r.NaN.clone():e?this.abs().lt("1e-300")?new r(this):this.small?r.fromNumber(c(this.toNumber())):this.lt(i)?r.fromNumber(c(this.sign*this.getOperator(0))):this.lt("eee15")?m(this):this.log():1===this.sign?r.NaN.clone():0===this.layer?r.fromNumber(c(this.sign*this.array[0].repeat,1e-10,!1)):1==this.layer?m(this,1e-10,!1):this.neg().rec().lambertw().neg()}},{key:"arrow",value:function(e){var t=this.clone(),a=new r(e);return!a.isInt()||a.lt(r.ZERO)?(console.warn("The arrow is <0 or not a integer, the returned function will return NaN."),function(){return r.NaN.clone()}):a.eq(0)?function(r){return t.mul(r)}:a.eq(1)?function(r){return t.pow(r)}:a.eq(2)?function(r){return t.tetrate(r)}:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=new r(e),s=r.arrowFuncMap.get("".concat(t.toString()," ").concat(a.toString()," ").concat(o.toString()," ").concat(n));if(s)return s.clone();var l=function(){var e;if(t.isNaN()||o.isNaN())return r.NaN.clone();if(o.lt(r.ZERO))return r.NaN.clone();if(t.eq(r.ZERO))return o.eq(r.ONE)?r.ZERO.clone():r.NaN.clone();if(t.eq(r.ONE))return r.ONE.clone();if(o.eq(r.ZERO))return r.ONE.clone();if(o.eq(r.ONE))return t.clone();if(a.gt(r.MSI))return(e=a.clone()).setOperator(e.getOperator(1/0)+1,1/0),e;var s=a.toNumber();if(o.eq(2))return t.arrow(s-1)(t,n+1);if(t.max(o).gt(r.arrowMSI(s+1)))return t.max(o);if(t.gt(r.arrowMSI(s))||o.gt(i)){t.gt(r.arrowMSI(s))?((e=t.clone()).setOperator(e.getOperator(s)-1,s),e.normalize()):e=t.gt(r.arrowMSI(s-1))?new r(t.getOperator(s-1)):r.ZERO;var l=e.add(o);return l.setOperator(l.getOperator(s)+1,s),l.normalize(),l}if(n>=r.maxOps+10)return new r({small:!1,sign:1,layer:0,array:[u(10,0),u(1,s)]});var h=o.toNumber(),f=Math.floor(h),g=a.sub(r.ONE);e=t.arrow(g)(h-f,n+1);for(var c=0,y=r.arrowMSI(s-1);0!==f&&e.lt(y)&&c<100;c++)f>0&&(e=t.arrow(g)(e,n+1),--f);return 100==c&&(f=0),e.setOperator(e.getOperator(s-1)+f,s-1),e.normalize(),e}();return n<r.maxOps+10&&r.arrowFuncMap.set("".concat(t.toString()," ").concat(a.toString()," ").concat(o.toString()," ").concat(n),l.clone()),l}}},{key:"chain",value:function(r,e){return this.arrow(e)(r)}},{key:"max",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.max.apply(r,[this].concat(t))}},{key:"min",value:function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return r.min.apply(r,[this].concat(t))}},{key:"maxabs",value:function(){for(var e=arguments.length,a=new Array(e),n=0;n<e;n++)a[n]=arguments[n];var i=a.map((function(e){return new r(e).abs()}));return r.max.apply(r,[this.abs()].concat(t(i)))}},{key:"minabs",value:function(){for(var e=arguments.length,a=new Array(e),n=0;n<e;n++)a[n]=arguments[n];var i=a.map((function(e){return new r(e).abs()}));return r.min.apply(r,[this.abs()].concat(t(i)))}},{key:"cmpabs",value:function(e){var t=new r(e).abs();return this.abs().cmp(t)}},{key:"neg",value:function(){var r=this.clone();return r.sign*=-1,r.normalize(),r}},{key:"rec",value:function(){var r=this.clone();return r.small=!r.small,r}},{key:"floor",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?r.ZERO.clone():r.ONE.neg().clone();var e=this.abs();return e.array[0].repeat=Math[1==this.sign?"floor":"ceil"](e.getOperator(0)),e}},{key:"ceil",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?r.ONE.clone():r.ZERO.clone();var e=this.abs();return e.array[0].repeat=Math[1==this.sign?"ceil":"floor"](e.getOperator(0)),e.sign=this.sign,e}},{key:"round",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?this.rec().lte(2)?r.ONE.clone():r.ZERO.clone():this.abs().rec().lte(2)?r.ZERO.clone():r.ONE.neg().clone();var e=this.abs();return e.array[0].repeat=Math.round(e.array[0].repeat),e.sign=this.sign,e}},{key:"trunc",value:function(){var r=this.clone();return r.gte(0)?r.floor():r.ceil()}},{key:"compare",value:function(e){var t=new r(e);if(this.isNaN()||t.isNaN())return 2;if(this.sign<t.sign)return-1;if(this.sign>t.sign)return 1;var a=-1==this.sign&&-1==t.sign;if(this.small&&!t.small)return-1*(a?-1:1);if(t.small&&!this.small)return 1*(a?-1:1);var n=1;this.small&&t.small&&(n*=-1),a&&(n*=-1);for(var i=0,o=0;this.array.length-1-o>=0&&t.array.length-1-o>=0;o++){var s=this.array[this.array.length-1-o],l=t.array[t.array.length-1-o],u=h([s.megota,s.expans,s.arrow,s.repeat],[l.megota,l.expans,l.arrow,l.repeat]);if(1==u){i=1;break}if(-1==u){i=-1;break}}return i*n+1-1}},{key:"cmp",value:function(r){return this.compare(r)}},{key:"eq",value:function(r){return 0===this.cmp(r)}},{key:"neq",value:function(r){return 0!==this.cmp(r)}},{key:"lt",value:function(r){return-1===this.cmp(r)}},{key:"lte",value:function(r){return this.cmp(r)<=0}},{key:"gt",value:function(r){return 1==this.cmp(r)}},{key:"gte",value:function(r){var e=this.cmp(r);return 0==e||1==e}},{key:"isNaN",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return isNaN(this.getOperator(0))}))},{key:"isZero",value:function(){return Boolean(this.small&&!isFinite(this.getOperator(0)))}},{key:"isFinite",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return Boolean(this.small||isFinite(this.getOperator(0)))&&!this.isNaN()}))},{key:"isInfi",value:function(){return this.rec().isZero()}},{key:"isInfiNaN",value:function(){return this.isInfi()||this.isNaN()}},{key:"isInt",value:function(){return!!this.isZero()||(!(this.small||!Number.isInteger(this.getOperator(0)))||!!this.abs().gte(i/2))}},{key:"ispos",value:function(){return this.sign>0}},{key:"isneg",value:function(){return this.sign<0}},{key:"normalize",value:function(){for(var e=!0,t=this,a=0;a<this.array.length;a++)if(this.array[a].repeat==1/0)return this.array=[{arrow:0,expans:1,megota:1,repeat:1/0}],this.layer=0,this;for(var n=1;n<t.array.length;++n){var s=t.array[n];if(null!==s.arrow&&void 0!==s.arrow||(s.arrow=0),null!==s.expans&&void 0!==s.expans||(s.expans=1),null!==s.megota&&void 0!==s.megota||(s.megota=1),isNaN(s.arrow)||isNaN(s.repeat)||isNaN(s.expans)||isNaN(s.megota))return t.array=[u(NaN,0,1,1)],t;if(!isFinite(s.repeat)||!isFinite(s.megota))return t.array=[u(1/0,0,1,1)],t;Number.isInteger(s.arrow)||(s.arrow=Math.floor(s.arrow)),Number.isInteger(s.repeat)||(s.repeat=Math.floor(s.repeat)),Number.isInteger(s.expans)||(s.expans=Math.floor(s.expans)),Number.isInteger(s.megota)||(s.megota=Math.floor(s.megota))}t.array.length||(t.small=!t.small,t.array=[u(1/0)]);do{for(e=!1,this.array.sort((function(r,e){return h([r.megota,r.expans,r.arrow],[e.megota,e.expans,e.arrow])})),n=1;n<t.array.length-1;++n)t.array[n].arrow==t.array[n+1].arrow&&t.array[n].expans==t.array[n+1].expans&&t.array[n].megota==t.array[n+1].megota&&(t.array[n].repeat+=t.array[n+1].repeat,t.array.splice(n+1,1),--n,e=!0);for(n=1;n<t.array.length;++n)0===t.array[n].arrow||0!==t.array[n].repeat&&null!==t.array[n].repeat&&void 0!==t.array[n].repeat?0==t.array[n].arrow&&t.array[n].expans>=2&&(t.array[n].arrow=1/0,t.array[n].valuereplaced=0,t.array[n].expans=t.array[n].expans-1):(t.array.splice(n,1),--n);for(t.array.length>r.maxOps&&t.array.splice(1,t.array.length-r.maxOps),this.array.length>=2&&1==this.array[1].arrow&&this.array[1].repeat>=1&&this.array[0].repeat<o&&(this.setOperator(this.array[1].repeat-1,1),this.setOperator(Math.pow(10,this.array[0].repeat),0),e=!0),this.getOperator(0)>i&&!isFinite(this.getOperator(0))&&(this.setOperator(this.getOperator(1)+1,1),this.setOperator(Math.log10(this.getOperator(0)),0),e=!0),1==this.array.length&&this.array[0].repeat<1&&(this.array[0].repeat=1/this.array[0].repeat,this.small=!this.small,e=!0);t.array.length>=2&&1==t.array[0].repeat&&t.array[1].repeat;)t.array[1].repeat>1?t.array[1].repeat--:t.array.splice(1,1),t.array[0].repeat=10,e=!0;t.array.length>=2&&t.array[0].repeat<i&&t.array[1].arrow>=2&&1==t.array[1].repeat&&isFinite(t.array[1].arrow)&&(t.array.splice(1,1,u(t.array[0].repeat,t.array[1].arrow-1,t.array[1].expans,t.array[1].megota)),t.array[0].repeat=10,e=!0),t.array.length>=2&&t.array[1].repeat>i&&(t.array[1].arrow++,t.array[0].repeat=t.array[1].repeat,t.array[1].repeat=1,e=!0)}while(e);return this}},{key:"getOperatorIndex",value:function(r){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=0;a<this.array.length;a++){var n=h([this.array[a].megota,this.array[a].expans,this.array[a].arrow],[t,e,r]);if(0==n)return a;if(1==n)return a-.5}return this.array.length-.5}},{key:"getOperator",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=this.getOperatorIndex(r,e,t);return this.array[a]?this.array[a].repeat:0}},{key:"setOperator",value:function(r,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=this.getOperatorIndex(e,t,a);return this.array[n]?(this.array[n].repeat=r,!1):(this.array.splice(Math.ceil(n),0,{arrow:e,expans:t,megota:a,valuereplaced:t===1/0?1:e==1/0?0:-1,repeat:r}),!0)}},{key:"clone",value:function(){var e=new r;return e.resetFromObject(this),e}},{key:"resetFromObject",value:function(r){this.array=[];for(var e=0;e<r.array.length;e++)this.array[e]={arrow:r.array[e].arrow,expans:r.array[e].expans,megota:r.array[e].megota,repeat:r.array[e].repeat,valuereplaced:r.array[e].valuereplaced};return this.small=r.small,this.sign=r.sign,this.layer=r.layer,this}},{key:"toNumber",value:function(){return-1==this.sign?-this.neg().toNumber():this.small?1/this.rec().toNumber():this.array.length>2?1/0:1==this.array.length?this.array[0].repeat:2==this.array.length&&1==this.array[1].arrow&&1==this.array[1].expans&&1==this.array[1].megota&&1==this.array[1].repeat?Math.pow(10,this.getOperator(0)):NaN}},{key:"toString",value:function(){if(this.isNaN())return"NaN";if(-1==this.sign)return"-".concat(this.neg().toString());if(this.small)return this.isZero()?"0":"/".concat(this.rec().toString());if(this.isInfi())return"Infinity";for(var r="",e=this.array.length-1;e>=0;e--){var t=this.array[e],a="10{".concat(t.arrow===1/0?"!":t.arrow).concat(t.expans>1||t.megota>1?",".concat(t.expans===1/0?"!":t.expans):"").concat(t.megota>1?",".concat(t.megota):"","}");a=1==t.arrow&&1==t.expans&&1==t.megota&&t.repeat<5?"e".repeat(t.repeat):0==t.arrow&&1==t.expans&&1==t.megota?t.repeat.toString():t.repeat>1?"(".concat(a,")^").concat(t.repeat," "):"".concat(a),r+="".concat(a)}return r}},{key:"toJSON",value:function(){return"PN"+this.toString()}},{key:"arr01",get:function(){for(var r=[0],e=0;e<this.array.length;e++)0==e?r[0]=this.array[e].repeat:(r[e]=[0,0,0,0],r[e][0]=this.array[e].arrow==1/0?"x":this.array[e].arrow,r[e][1]=this.array[e].repeat,r[e][2]=this.array[e].expans==1/0?"x":this.array[e].expans,r[e][3]=this.array[e].megota);return r}}],[{key:"add",value:function(e,t){return new r(e).add(t)}},{key:"sub",value:function(e,t){return new r(e).sub(t)}},{key:"mul",value:function(e,t){return new r(e).mul(t)}},{key:"div",value:function(e,t){return new r(e).div(t)}},{key:"pow",value:function(e,t){return new r(e).pow(t)}},{key:"root",value:function(e,t){return new r(e).root(t)}},{key:"sqrt",value:function(e){return new r(e).sqrt()}},{key:"cbrt",value:function(e){return new r(e).cbrt()}},{key:"tetrate",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return new r(e).tetrate(t,a)}},{key:"log10",value:function(e){return new r(e).log10()}},{key:"log",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new r(e).log(t)}},{key:"plog10",value:function(e){return new r(e).plog10()}},{key:"plog",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new r(e).plog(t)}},{key:"exp",value:function(e){return new r(e).pow_base(Math.E)}},{key:"factorial",value:function(e){return new r(e).factorial()}},{key:"gamma",value:function(e){return new r(e).gamma()}},{key:"lambertw",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new r(e).lambertw(t)}},{key:"tetrate_10",value:function(e){return r.fromNumber(10).tetrate(e)}},{key:"max",value:function(){for(var e=r.NEGATIVE_INFINITY,t=arguments.length,a=new Array(t),n=0;n<t;n++)a[n]=arguments[n];for(var i=0;i<a.length;i++)e.lt(a[i])&&(e=new r(a[i]).clone());return e}},{key:"min",value:function(){for(var e=r.POSITIVE_INFINITY,t=arguments.length,a=new Array(t),n=0;n<t;n++)a[n]=arguments[n];for(var i=0;i<a.length;i++)e.gt(a[i])&&(e=new r(a[i]).clone());return e}},{key:"clampMin",value:function(){return r.max.apply(r,arguments)}},{key:"clampMax",value:function(){return r.min.apply(r,arguments)}},{key:"sign",value:function(e){return new r(e).sign}},{key:"isNaN",value:function(e){return new r(e).isNaN()}},{key:"arrowMSI",value:function(e){return new r("10{".concat(e,"}").concat(i))}},{key:"fromNumber",value:function(e){var t=new r;if(e<0)t.sign=-1;else{if(0==e)return t.sign=0,t.small=!0,t.array=[u(1/0,0)],t;e>0&&(t.sign=1)}var a=Math.abs(e);return a>=11102230246251568e-32&&a<1?(t.small=!0,t.array=[u(1/a,0)]):a<11102230246251568e-32?(t.small=!0,t.array=[u(-Math.log10(a),0),u(1,1)]):a<=i?t.array=[u(a,0)]:(t.setOperator(Math.log10(a),0),t.array=[u(Math.log10(a),0),u(1,1)]),t}},{key:"fromString",value:function(e){var t,a,n,s,h,g,c,y=new r;if(e.startsWith("PN")&&(e=e.substring(2)),!isNaN(Number(e))){var p=Number(e),m=!1;if(0==p?/^(0*\.0*e)|(0*\.0*)$/.test(e)&&(m=!0):m=!0,!m){var v=e.search(/e/),N=e.substring((-1==v?e.length:v)+1),w=e.substring(0,-1==v?void 0:v),b=[0,0];if(b[1]=Number(N||"0"),Number(w)>=1){var I=w.length>=17?f(w):Math.log10(Number(w)),d=I-(Math.floor(I)-1);b[0]=Math.pow(10,d),b[1]+=d}else{var E=(c=w.match(/^0\.(0*)[1-9]/))?c[1].length:0;w=(w=w.substring(w.search(/[1-9]/))).charAt(0)+"."+w.substring(1),E+=1,b[0]=Number(w),b[1]+=-E}return r.pow(10,-b[1]-1).mul(10*Math.pow(b[0],-1)).rec()}if(isFinite(p)&&m)return y.resetFromObject(r.fromNumber(Number(e))),y}if(e=e.replace(/\(e\^(\d+)\)/g,"(10^)^$1 ").replace(/(\d+)\x20*PT/g,"(10^)^$1 "),!l.test(e))throw"[PowiainaNum 0.2 error]malformed input: "+e;var O=!1,M=!1;if("-"==e[0]||"+"==e[0]){var k=e.search(/[^-\+]/);O=(null!==(a=null===(t=e.substring(0,k).match(/-/g))||void 0===t?void 0:t.length)&&void 0!==a?a:0)%2==1,e=e.substring(k)}if("/"==e[0]){k=e.search(/[^\/]/);M=(null!==(s=null===(n=e.substring(0,k).match(/\//g))||void 0===n?void 0:n.length)&&void 0!==s?s:0)%2==1,e=e.substring(k)}if("NaN"==e)y.array=[u(NaN)];else if("Infinity"==e)y.array=[u(1/0)];else{var x,T,S,_;for(y.sign=1,y.array=[u(0)];e&&/^(\(?10[\^\{])/.test(e);){var F,q,R;if("("==e[0]&&(e=e.substring(1)),"^"==e[2])F=x=e.substring(2).search(/[^\^]/),T=x+2;else{x=e.indexOf("}");var A=e.substring(3,x).split(",");F=Number("!"==A[0]?1/0:A[0]),q=Number(null!==(h="!"==A[1]?1/0:A[1])&&void 0!==h?h:1),R=Number(null!==(g=A[2])&&void 0!==g?g:1),T=x+1}")"==(e=e.substring(T))[0]?(x=e.indexOf(" "),S=Number(e.substring(2,x)),e=e.substring(x+1)):S=1,1==F&&1==q&&1==R?y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat+=S:y.array.splice(1,0,u(S,1,q,R)):2==F&&1==q&&1==R?(x=y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat:0,(T=y.array[0].repeat)>=1e10&&++x,T>=10&&++x,y.array[0].repeat=x,y.array.length>=2&&1==y.array[1].arrow&&y.array.splice(1,1),_=y.getOperatorIndex(2),Number.isInteger(_)?y.array[_].repeat+=S:y.array.splice(Math.ceil(_),0,u(S,2,q,R))):isFinite(F)?(x=y.getOperator(F-1),(T=y.getOperator(F-2))>=10&&++x,_=y.getOperatorIndex(F),y.array.splice(1,Math.ceil(_)-1),y.array[0].repeat=x,Number.isInteger(_)?y.array[1].repeat+=S:y.array.splice(1,0,u(S,F,q,R))):y.array.splice(1,0,u(S,F,q,R))}x=e.split(/[Ee]/),T=[y.array[0].repeat,0],S=1;for(var Z=x.length-1;Z>=0;--Z){T[0]<o&&0===T[1]?T[0]=Math.pow(10,S*T[0]):-1==S?(0===T[1]?T[0]=Math.pow(10,S*T[0]):1==T[1]&&T[0]<=Math.log10(Number.MAX_VALUE)?T[0]=Math.pow(10,S*Math.pow(10,T[0])):T[0]=0,T[1]=0):T[1]++;var P=x[Z].indexOf("."),V=-1==P?x[Z].length:P;0===T[1]?V>=17?(T[0]=Math.log10(T[0])+f(x[Z].substring(0,V)),T[1]=1):x[Z]&&(T[0]*=Number(x[Z])):(_=V>=17?f(x[Z].substring(0,V)):x[Z]?Math.log10(Number(x[Z])):0,1==T[1]?T[0]+=_:2==T[1]&&T[0]<o+Math.log10(_)&&(T[0]+=Math.log10(1+Math.pow(10,Math.log10(_)-T[0])))),T[0]<o&&T[1]?(T[0]=Math.pow(10,T[0]),T[1]--):T[0]>i&&(T[0]=Math.log10(T[0]),T[1]++)}y.array[0].repeat=T[0],T[1]&&(y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat+=T[1]:y.array.splice(1,0,u(T[1],1,1,1)))}return O&&(y.sign*=-1),M&&(y.small=!y.small),y.normalize(),y.normalize(),y}},{key:"fromObject",value:function(e){var t=new r;if(t.array=[],function(r){if(!Array.isArray(r))return!1;for(var e=0;e<r.length;e++){var t=r[e];if(!Array.isArray(t))return!1;if(!y(t))return!1;if(!p(t))return!1}return!0}(e)){for(var a=0;a<e.length;a++)t.array[a]={arrow:e[a][0],expans:1,megota:1,repeat:e[a][1]};return t.small=!1,t.sign=1,t.layer=0,t}for(var n=0;n<e.array.length;n++)t.array[n]={arrow:e.array[n].arrow,expans:e.array[n].expans,megota:e.array[n].megota,repeat:e.array[n].repeat,valuereplaced:e.array[n].valuereplaced};return t.small=e.small,t.sign=e.sign,t.layer=e.layer,t}}])}();return N.ZERO=new N({array:[{arrow:0,expans:1,megota:1,repeat:1/0}],small:!0,layer:0,sign:0}),N.ONE=new N({array:[{arrow:0,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),N.MSI=new N(i),N.MSI_REC=((v=new N(i)).small=!0,v),N.E_MSI=new N({array:[{arrow:0,expans:1,megota:1,repeat:i},{arrow:1,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),N.E_MSI_REC=new N({array:[{arrow:0,expans:1,megota:1,repeat:i},{arrow:1,expans:1,megota:1,repeat:1}],small:!0,layer:0,sign:1}),N.TETRATED_MSI=new N({array:[{arrow:0,expans:1,megota:1,repeat:1e10},{arrow:1,expans:1,megota:1,repeat:i-2}],small:!1,layer:0,sign:1}),N.PENTATED_MSI=new N({array:[{arrow:0,expans:1,megota:1,repeat:10},{arrow:2,expans:1,megota:1,repeat:i-1}],small:!1,layer:0,sign:1}),N.TRITRI=new N({small:!1,layer:0,sign:1,array:[u(3638334640023.7783,0,1,1),u(7625587484984,1,1,1)]}),N.GRAHAMS_NUMBER=new N("(10{!})^63 10^^^(10^)^7625597484984 3638334640023.7783"),N.POSITIVE_INFINITY=new N(1/0),N.NEGATIVE_INFINITY=new N(-1/0),N.NaN=new N({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),N.E=new N(Math.E),N.LN2=new N(Math.LN2),N.LN10=new N(Math.LN10),N.LOG2E=new N(Math.LOG2E),N.LOG10E=new N(Math.LOG10E),N.PI=new N(Math.PI),N.SQRT1_2=new N(Math.SQRT1_2),N.SQRT2=new N(Math.SQRT2),N.maxOps=100,N.arrowFuncMap=new Map,N}));
|
package/package.json
CHANGED