smart-unit 1.0.3 → 1.0.5

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 CHANGED
@@ -5,6 +5,7 @@
5
5
  [![npm version](https://img.shields.io/npm/v/smart-unit)](https://www.npmjs.com/package/smart-unit)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/smart-unit)](https://www.npmjs.com/package/smart-unit)
7
7
  [![bundle size](https://img.shields.io/bundlephobia/minzip/smart-unit)](https://bundlephobia.com/package/smart-unit)
8
+ [![test](https://github.com/flycran/smart-unit/workflows/Test/badge.svg)](https://github.com/flycran/smart-unit/actions)
8
9
  [![license](https://img.shields.io/npm/l/smart-unit)](./LICENSE)
9
10
 
10
11
  English | [中文](./README.zh-CN.md)
@@ -13,6 +14,16 @@ English | [中文](./README.zh-CN.md)
13
14
 
14
15
  **smart-unit** is a lightweight utility for automatic unit conversion with intelligent formatting.
15
16
 
17
+ ```ts
18
+ import SmartUnit from 'smart-unit';
19
+
20
+ const size = new SmartUnit(['B', 'KB', 'MB', 'GB'], { baseDigit: 1024 });
21
+
22
+ size.format(1024 * 1024 * 100); // "100MB"
23
+ size.format(1536); // "1.5KB"
24
+ size.parse('2.5GB'); // 2684354560
25
+ ```
26
+
16
27
  ## Features
17
28
 
18
29
  - 🎯 **Smart Formatting** — Automatically selects the optimal unit for display
@@ -21,6 +32,7 @@ English | [中文](./README.zh-CN.md)
21
32
  - 🧮 **High Precision** — Optional `decimal.js` integration for arbitrary precision
22
33
  - 📦 **TypeScript First** — Full type safety
23
34
  - 🪶 **Lightweight** — Core functionality with minimal footprint
35
+ - ✅ **Well Tested** — Comprehensive test suite with 100% coverage
24
36
 
25
37
  ## Install
26
38
 
@@ -104,7 +116,7 @@ Formats a number to the optimal unit string.
104
116
  ```ts
105
117
  const size = new SmartUnit(['B', 'KB', 'MB'], { baseDigit: 1024, fractionDigits: 2 });
106
118
 
107
- size.format(1536); // => "1.5KB"
119
+ size.format(1536); // => "1.50KB"
108
120
  size.format(1536, 0); // => "2KB"
109
121
  size.format(1536, '1-3'); // => "1.5KB" (min 1, max 3 decimals)
110
122
  ```
@@ -203,6 +215,14 @@ const currency = new SmartUnit(['', 'K', 'M', 'B', 'T'], {
203
215
  currency.format('12345678901234567890'); // => "12345678.90T"
204
216
  ```
205
217
 
218
+ ## Testing
219
+
220
+ Run the test suite:
221
+
222
+ ```bash
223
+ npm test
224
+ ```
225
+
206
226
  ## TypeScript
207
227
 
208
228
  smart-unit is written in TypeScript and provides full type safety.
package/README.zh-CN.md CHANGED
@@ -5,6 +5,7 @@
5
5
  [![npm version](https://img.shields.io/npm/v/smart-unit)](https://www.npmjs.com/package/smart-unit)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/smart-unit)](https://www.npmjs.com/package/smart-unit)
7
7
  [![bundle size](https://img.shields.io/bundlephobia/minzip/smart-unit)](https://bundlephobia.com/package/smart-unit)
8
+ [![test](https://github.com/flycran/smart-unit/workflows/Test/badge.svg)](https://github.com/flycran/smart-unit/actions)
8
9
  [![license](https://img.shields.io/npm/l/smart-unit)](./LICENSE)
9
10
 
10
11
  [English](./README.md) | 中文
@@ -13,6 +14,16 @@
13
14
 
14
15
  **smart-unit** 是一个轻量级的自动单位转换工具,支持智能格式化输出。
15
16
 
17
+ ```ts
18
+ import SmartUnit from 'smart-unit';
19
+
20
+ const size = new SmartUnit(['B', 'KB', 'MB', 'GB'], { baseDigit: 1024 });
21
+
22
+ size.format(1024 * 1024 * 100); // "100MB"
23
+ size.format(1536); // "1.5KB"
24
+ size.parse('2.5GB'); // 2684354560
25
+ ```
26
+
16
27
  ## 特性
17
28
 
18
29
  - 🎯 **智能格式化** — 自动选择最优单位进行展示
@@ -21,6 +32,7 @@
21
32
  - 🧮 **高精度** — 可选 `decimal.js` 集成,支持任意精度计算
22
33
  - 📦 **TypeScript 优先** — 完整的类型安全
23
34
  - 🪶 **轻量级** — 核心功能,体积小巧
35
+ - ✅ **测试完善** — 全面的测试套件,100% 覆盖率
24
36
 
25
37
  ## 安装
26
38
 
@@ -104,7 +116,7 @@ time.parse('2.5h'); // => 9000000 (ms)
104
116
  ```ts
105
117
  const size = new SmartUnit(['B', 'KB', 'MB'], { baseDigit: 1024, fractionDigits: 2 });
106
118
 
107
- size.format(1536); // => "1.5KB"
119
+ size.format(1536); // => "1.50KB"
108
120
  size.format(1536, 0); // => "2KB"
109
121
  size.format(1536, '1-3'); // => "1.5KB"(最少1位,最多3位小数)
110
122
  ```
@@ -203,6 +215,14 @@ const currency = new SmartUnit(['', 'K', 'M', 'B', 'T'], {
203
215
  currency.format('12345678901234567890'); // => "12345678.90T"
204
216
  ```
205
217
 
218
+ ## 测试
219
+
220
+ 运行测试套件:
221
+
222
+ ```bash
223
+ npm test
224
+ ```
225
+
206
226
  ## TypeScript
207
227
 
208
228
  smart-unit 使用 TypeScript 编写,提供完整的类型安全。
@@ -5,10 +5,10 @@
5
5
  * https://github.com/MikeMcl/decimal.js
6
6
  * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
7
7
  * MIT Licence
8
- */var e,i,t=9e15,r=1e9,s="0123456789abcdef",o="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",u="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",c={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9e15,maxE:t,crypto:!1},f=!0,h="[DecimalError] ",a=h+"Invalid argument: ",l=h+"Precision limit exceeded",d=h+"crypto unavailable",g="[object Decimal]",p=Math.floor,m=Math.pow,w=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,v=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,N=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,b=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,E=1e7,y=o.length-1,x=u.length-1,S={toStringTag:g};function M(n){var e,i,t,r=n.length-1,s="",o=n[0];if(r>0){for(s+=o,e=1;e<r;e++)(i=7-(t=n[e]+"").length)&&(s+=Z(i)),s+=t;(i=7-(t=(o=n[e])+"").length)&&(s+=Z(i))}else if(0===o)return"0";for(;o%10==0;)o/=10;return s+o}function O(n,e,i){if(n!==~~n||n<e||n>i)throw Error(a+n)}function q(n,e,i,t){var r,s,o,u;for(s=n[0];s>=10;s/=10)--e;return--e<0?(e+=7,r=0):(r=Math.ceil((e+1)/7),e%=7),s=m(10,7-e),u=n[r]%s|0,null==t?e<3?(0==e?u=u/100|0:1==e&&(u=u/10|0),o=i<4&&99999==u||i>3&&49999==u||5e4==u||0==u):o=(i<4&&u+1==s||i>3&&u+1==s/2)&&(n[r+1]/s/100|0)==m(10,e-2)-1||(u==s/2||0==u)&&!(n[r+1]/s/100|0):e<4?(0==e?u=u/1e3|0:1==e?u=u/100|0:2==e&&(u=u/10|0),o=(t||i<4)&&9999==u||!t&&i>3&&4999==u):o=((t||i<4)&&u+1==s||!t&&i>3&&u+1==s/2)&&(n[r+1]/s/1e3|0)==m(10,e-3)-1,o}function D(n,e,i){for(var t,r,o=[0],u=0,c=n.length;u<c;){for(r=o.length;r--;)o[r]*=e;for(o[0]+=s.indexOf(n.charAt(u++)),t=0;t<o.length;t++)o[t]>i-1&&(void 0===o[t+1]&&(o[t+1]=0),o[t+1]+=o[t]/i|0,o[t]%=i)}return o.reverse()}S.absoluteValue=S.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),T(n)},S.ceil=function(){return T(new this.constructor(this),this.e+1,2)},S.clampedTo=S.clamp=function(n,e){var i=this,t=i.constructor;if(n=new t(n),e=new t(e),!n.s||!e.s)return new t(NaN);if(n.gt(e))throw Error(a+e);return i.cmp(n)<0?n:i.cmp(e)>0?e:new t(i)},S.comparedTo=S.cmp=function(n){var e,i,t,r,s=this,o=s.d,u=(n=new s.constructor(n)).d,c=s.s,f=n.s;if(!o||!u)return c&&f?c!==f?c:o===u?0:!o^c<0?1:-1:NaN;if(!o[0]||!u[0])return o[0]?c:u[0]?-f:0;if(c!==f)return c;if(s.e!==n.e)return s.e>n.e^c<0?1:-1;for(e=0,i=(t=o.length)<(r=u.length)?t:r;e<i;++e)if(o[e]!==u[e])return o[e]>u[e]^c<0?1:-1;return t===r?0:t>r^c<0?1:-1},S.cosine=S.cos=function(){var n,e,t=this,r=t.constructor;return t.d?t.d[0]?(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+7,r.rounding=1,t=function(n,e){var i,t,r;if(e.isZero())return e;t=e.d.length,t<32?r=(1/W(4,i=Math.ceil(t/3))).toString():(i=16,r="2.3283064365386962890625e-10");n.precision+=i,e=V(n,1,e.times(r),new n(1));for(var s=i;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=i,e}(r,G(r,t)),r.precision=n,r.rounding=e,T(2==i||3==i?t.neg():t,n,e,!0)):new r(1):new r(NaN)},S.cubeRoot=S.cbrt=function(){var n,e,i,t,r,s,o,u,c,h,a=this,l=a.constructor;if(!a.isFinite()||a.isZero())return new l(a);for(f=!1,(s=a.s*m(a.s*a,1/3))&&Math.abs(s)!=1/0?t=new l(s.toString()):(i=M(a.d),(s=((n=a.e)-i.length+1)%3)&&(i+=1==s||-2==s?"0":"00"),s=m(i,1/3),n=p((n+1)/3)-(n%3==(n<0?-1:2)),(t=new l(i=s==1/0?"5e"+n:(i=s.toExponential()).slice(0,i.indexOf("e")+1)+n)).s=a.s),o=(n=l.precision)+3;;)if(h=(c=(u=t).times(u).times(u)).plus(a),t=F(h.plus(a).times(u),h.plus(c),o+2,1),M(u.d).slice(0,o)===(i=M(t.d)).slice(0,o)){if("9999"!=(i=i.slice(o-3,o+1))&&(r||"4999"!=i)){+i&&(+i.slice(1)||"5"!=i.charAt(0))||(T(t,n+1,1),e=!t.times(t).times(t).eq(a));break}if(!r&&(T(u,n+1,0),u.times(u).times(u).eq(a))){t=u;break}o+=4,r=1}return f=!0,T(t,n,l.rounding,e)},S.decimalPlaces=S.dp=function(){var n,e=this.d,i=NaN;if(e){if(i=7*((n=e.length-1)-p(this.e/7)),n=e[n])for(;n%10==0;n/=10)i--;i<0&&(i=0)}return i},S.dividedBy=S.div=function(n){return F(this,new this.constructor(n))},S.dividedToIntegerBy=S.divToInt=function(n){var e=this.constructor;return T(F(this,new e(n),0,1,1),e.precision,e.rounding)},S.equals=S.eq=function(n){return 0===this.cmp(n)},S.floor=function(){return T(new this.constructor(this),this.e+1,3)},S.greaterThan=S.gt=function(n){return this.cmp(n)>0},S.greaterThanOrEqualTo=S.gte=function(n){var e=this.cmp(n);return 1==e||0===e},S.hyperbolicCosine=S.cosh=function(){var n,e,i,t,r,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;i=o.precision,t=o.rounding,o.precision=i+Math.max(s.e,s.sd())+4,o.rounding=1,(r=s.d.length)<32?e=(1/W(4,n=Math.ceil(r/3))).toString():(n=16,e="2.3283064365386962890625e-10"),s=V(o,1,s.times(e),new o(1),!0);for(var c,f=n,h=new o(8);f--;)c=s.times(s),s=u.minus(c.times(h.minus(c.times(h))));return T(s,o.precision=i,o.rounding=t,!0)},S.hyperbolicSine=S.sinh=function(){var n,e,i,t,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(e=s.precision,i=s.rounding,s.precision=e+Math.max(r.e,r.sd())+4,s.rounding=1,(t=r.d.length)<3)r=V(s,2,r,r,!0);else{n=(n=1.4*Math.sqrt(t))>16?16:0|n,r=V(s,2,r=r.times(1/W(5,n)),r,!0);for(var o,u=new s(5),c=new s(16),f=new s(20);n--;)o=r.times(r),r=r.times(u.plus(o.times(c.times(o).plus(f))))}return s.precision=e,s.rounding=i,T(r,e,i,!0)},S.hyperbolicTangent=S.tanh=function(){var n,e,i=this,t=i.constructor;return i.isFinite()?i.isZero()?new t(i):(n=t.precision,e=t.rounding,t.precision=n+7,t.rounding=1,F(i.sinh(),i.cosh(),t.precision=n,t.rounding=e)):new t(i.s)},S.inverseCosine=S.acos=function(){var n=this,e=n.constructor,i=n.abs().cmp(1),t=e.precision,r=e.rounding;return-1!==i?0===i?n.isNeg()?P(e,t,r):new e(0):new e(NaN):n.isZero()?P(e,t+4,r).times(.5):(e.precision=t+6,e.rounding=1,n=new e(1).minus(n).div(n.plus(1)).sqrt().atan(),e.precision=t,e.rounding=r,n.times(2))},S.inverseHyperbolicCosine=S.acosh=function(){var n,e,i=this,t=i.constructor;return i.lte(1)?new t(i.eq(1)?0:NaN):i.isFinite()?(n=t.precision,e=t.rounding,t.precision=n+Math.max(Math.abs(i.e),i.sd())+4,t.rounding=1,f=!1,i=i.times(i).minus(1).sqrt().plus(i),f=!0,t.precision=n,t.rounding=e,i.ln()):new t(i)},S.inverseHyperbolicSine=S.asinh=function(){var n,e,i=this,t=i.constructor;return!i.isFinite()||i.isZero()?new t(i):(n=t.precision,e=t.rounding,t.precision=n+2*Math.max(Math.abs(i.e),i.sd())+6,t.rounding=1,f=!1,i=i.times(i).plus(1).sqrt().plus(i),f=!0,t.precision=n,t.rounding=e,i.ln())},S.inverseHyperbolicTangent=S.atanh=function(){var n,e,i,t,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=s.precision,e=s.rounding,t=r.sd(),Math.max(t,n)<2*-r.e-1?T(new s(r),n,e,!0):(s.precision=i=t-r.e,r=F(r.plus(1),new s(1).minus(r),i+n,1),s.precision=n+4,s.rounding=1,r=r.ln(),s.precision=n,s.rounding=e,r.times(.5))):new s(NaN)},S.inverseSine=S.asin=function(){var n,e,i,t,r=this,s=r.constructor;return r.isZero()?new s(r):(e=r.abs().cmp(1),i=s.precision,t=s.rounding,-1!==e?0===e?((n=P(s,i+4,t).times(.5)).s=r.s,n):new s(NaN):(s.precision=i+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=i,s.rounding=t,r.times(2)))},S.inverseTangent=S.atan=function(){var n,e,i,t,r,s,o,u,c,h=this,a=h.constructor,l=a.precision,d=a.rounding;if(h.isFinite()){if(h.isZero())return new a(h);if(h.abs().eq(1)&&l+4<=x)return(o=P(a,l+4,d).times(.25)).s=h.s,o}else{if(!h.s)return new a(NaN);if(l+4<=x)return(o=P(a,l+4,d).times(.5)).s=h.s,o}for(a.precision=u=l+10,a.rounding=1,n=i=Math.min(28,u/7+2|0);n;--n)h=h.div(h.times(h).plus(1).sqrt().plus(1));for(f=!1,e=Math.ceil(u/7),t=1,c=h.times(h),o=new a(h),r=h;-1!==n;)if(r=r.times(c),s=o.minus(r.div(t+=2)),r=r.times(c),void 0!==(o=s.plus(r.div(t+=2))).d[e])for(n=e;o.d[n]===s.d[n]&&n--;);return i&&(o=o.times(2<<i-1)),f=!0,T(o,a.precision=l,a.rounding=d,!0)},S.isFinite=function(){return!!this.d},S.isInteger=S.isInt=function(){return!!this.d&&p(this.e/7)>this.d.length-2},S.isNaN=function(){return!this.s},S.isNegative=S.isNeg=function(){return this.s<0},S.isPositive=S.isPos=function(){return this.s>0},S.isZero=function(){return!!this.d&&0===this.d[0]},S.lessThan=S.lt=function(n){return this.cmp(n)<0},S.lessThanOrEqualTo=S.lte=function(n){return this.cmp(n)<1},S.logarithm=S.log=function(n){var e,i,t,r,s,o,u,c,h=this,a=h.constructor,l=a.precision,d=a.rounding;if(null==n)n=new a(10),e=!0;else{if(i=(n=new a(n)).d,n.s<0||!i||!i[0]||n.eq(1))return new a(NaN);e=n.eq(10)}if(i=h.d,h.s<0||!i||!i[0]||h.eq(1))return new a(i&&!i[0]?-1/0:1!=h.s?NaN:i?0:1/0);if(e)if(i.length>1)s=!0;else{for(r=i[0];r%10==0;)r/=10;s=1!==r}if(f=!1,o=$(h,u=l+5),t=e?A(a,u+10):$(n,u),q((c=F(o,t,u,1)).d,r=l,d))do{if(o=$(h,u+=10),t=e?A(a,u+10):$(n,u),c=F(o,t,u,1),!s){+M(c.d).slice(r+1,r+15)+1==1e14&&(c=T(c,l+1,0));break}}while(q(c.d,r+=10,d));return f=!0,T(c,l,d)},S.minus=S.sub=function(n){var e,i,t,r,s,o,u,c,h,a,l,d,g=this,m=g.constructor;if(n=new m(n),!g.d||!n.d)return g.s&&n.s?g.d?n.s=-n.s:n=new m(n.d||g.s!==n.s?g:NaN):n=new m(NaN),n;if(g.s!=n.s)return n.s=-n.s,g.plus(n);if(h=g.d,d=n.d,u=m.precision,c=m.rounding,!h[0]||!d[0]){if(d[0])n.s=-n.s;else{if(!h[0])return new m(3===c?-0:0);n=new m(g)}return f?T(n,u,c):n}if(i=p(n.e/7),a=p(g.e/7),h=h.slice(),s=a-i){for((l=s<0)?(e=h,s=-s,o=d.length):(e=d,i=a,o=h.length),s>(t=Math.max(Math.ceil(u/7),o)+2)&&(s=t,e.length=1),e.reverse(),t=s;t--;)e.push(0);e.reverse()}else{for((l=(t=h.length)<(o=d.length))&&(o=t),t=0;t<o;t++)if(h[t]!=d[t]){l=h[t]<d[t];break}s=0}for(l&&(e=h,h=d,d=e,n.s=-n.s),o=h.length,t=d.length-o;t>0;--t)h[o++]=0;for(t=d.length;t>s;){if(h[--t]<d[t]){for(r=t;r&&0===h[--r];)h[r]=E-1;--h[r],h[t]+=E}h[t]-=d[t]}for(;0===h[--o];)h.pop();for(;0===h[0];h.shift())--i;return h[0]?(n.d=h,n.e=U(h,i),f?T(n,u,c):n):new m(3===c?-0:0)},S.modulo=S.mod=function(n){var e,i=this,t=i.constructor;return n=new t(n),!i.d||!n.s||n.d&&!n.d[0]?new t(NaN):!n.d||i.d&&!i.d[0]?T(new t(i),t.precision,t.rounding):(f=!1,9==t.modulo?(e=F(i,n.abs(),0,3,1)).s*=n.s:e=F(i,n,0,t.modulo,1),e=e.times(n),f=!0,i.minus(e))},S.naturalExponential=S.exp=function(){return L(this)},S.naturalLogarithm=S.ln=function(){return $(this)},S.negated=S.neg=function(){var n=new this.constructor(this);return n.s=-n.s,T(n)},S.plus=S.add=function(n){var e,i,t,r,s,o,u,c,h,a,l=this,d=l.constructor;if(n=new d(n),!l.d||!n.d)return l.s&&n.s?l.d||(n=new d(n.d||l.s===n.s?l:NaN)):n=new d(NaN),n;if(l.s!=n.s)return n.s=-n.s,l.minus(n);if(h=l.d,a=n.d,u=d.precision,c=d.rounding,!h[0]||!a[0])return a[0]||(n=new d(l)),f?T(n,u,c):n;if(s=p(l.e/7),t=p(n.e/7),h=h.slice(),r=s-t){for(r<0?(i=h,r=-r,o=a.length):(i=a,t=s,o=h.length),r>(o=(s=Math.ceil(u/7))>o?s+1:o+1)&&(r=o,i.length=1),i.reverse();r--;)i.push(0);i.reverse()}for((o=h.length)-(r=a.length)<0&&(r=o,i=a,a=h,h=i),e=0;r;)e=(h[--r]=h[r]+a[r]+e)/E|0,h[r]%=E;for(e&&(h.unshift(e),++t),o=h.length;0==h[--o];)h.pop();return n.d=h,n.e=U(h,t),f?T(n,u,c):n},S.precision=S.sd=function(n){var e,i=this;if(void 0!==n&&n!==!!n&&1!==n&&0!==n)throw Error(a+n);return i.d?(e=_(i.d),n&&i.e+1>e&&(e=i.e+1)):e=NaN,e},S.round=function(){var n=this,e=n.constructor;return T(new e(n),n.e+1,e.rounding)},S.sine=S.sin=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+Math.max(t.e,t.sd())+7,r.rounding=1,t=function(n,e){var i,t=e.d.length;if(t<3)return e.isZero()?e:V(n,2,e,e);i=(i=1.4*Math.sqrt(t))>16?16:0|i,e=e.times(1/W(5,i)),e=V(n,2,e,e);for(var r,s=new n(5),o=new n(16),u=new n(20);i--;)r=e.times(e),e=e.times(s.plus(r.times(o.times(r).minus(u))));return e}(r,G(r,t)),r.precision=n,r.rounding=e,T(i>2?t.neg():t,n,e,!0)):new r(NaN)},S.squareRoot=S.sqrt=function(){var n,e,i,t,r,s,o=this,u=o.d,c=o.e,h=o.s,a=o.constructor;if(1!==h||!u||!u[0])return new a(!h||h<0&&(!u||u[0])?NaN:u?o:1/0);for(f=!1,0==(h=Math.sqrt(+o))||h==1/0?(((e=M(u)).length+c)%2==0&&(e+="0"),h=Math.sqrt(e),c=p((c+1)/2)-(c<0||c%2),t=new a(e=h==1/0?"5e"+c:(e=h.toExponential()).slice(0,e.indexOf("e")+1)+c)):t=new a(h.toString()),i=(c=a.precision)+3;;)if(t=(s=t).plus(F(o,s,i+2,1)).times(.5),M(s.d).slice(0,i)===(e=M(t.d)).slice(0,i)){if("9999"!=(e=e.slice(i-3,i+1))&&(r||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(T(t,c+1,1),n=!t.times(t).eq(o));break}if(!r&&(T(s,c+1,0),s.times(s).eq(o))){t=s;break}i+=4,r=1}return f=!0,T(t,c,a.rounding,n)},S.tangent=S.tan=function(){var n,e,t=this,r=t.constructor;return t.isFinite()?t.isZero()?new r(t):(n=r.precision,e=r.rounding,r.precision=n+10,r.rounding=1,(t=t.sin()).s=1,t=F(t,new r(1).minus(t.times(t)).sqrt(),n+10,0),r.precision=n,r.rounding=e,T(2==i||4==i?t.neg():t,n,e,!0)):new r(NaN)},S.times=S.mul=function(n){var e,i,t,r,s,o,u,c,h,a=this,l=a.constructor,d=a.d,g=(n=new l(n)).d;if(n.s*=a.s,!(d&&d[0]&&g&&g[0]))return new l(!n.s||d&&!d[0]&&!g||g&&!g[0]&&!d?NaN:d&&g?0*n.s:n.s/0);for(i=p(a.e/7)+p(n.e/7),(c=d.length)<(h=g.length)&&(s=d,d=g,g=s,o=c,c=h,h=o),s=[],t=o=c+h;t--;)s.push(0);for(t=h;--t>=0;){for(e=0,r=c+t;r>t;)u=s[r]+g[t]*d[r-t-1]+e,s[r--]=u%E|0,e=u/E|0;s[r]=(s[r]+e)%E|0}for(;!s[--o];)s.pop();return e?++i:s.shift(),n.d=s,n.e=U(s,i),f?T(n,l.precision,l.rounding):n},S.toBinary=function(n,e){return J(this,2,n,e)},S.toDecimalPlaces=S.toDP=function(n,e){var i=this,t=i.constructor;return i=new t(i),void 0===n?i:(O(n,0,r),void 0===e?e=t.rounding:O(e,0,8),T(i,n+i.e+1,e))},S.toExponential=function(n,e){var i,t=this,s=t.constructor;return void 0===n?i=R(t,!0):(O(n,0,r),void 0===e?e=s.rounding:O(e,0,8),i=R(t=T(new s(t),n+1,e),!0,n+1)),t.isNeg()&&!t.isZero()?"-"+i:i},S.toFixed=function(n,e){var i,t,s=this,o=s.constructor;return void 0===n?i=R(s):(O(n,0,r),void 0===e?e=o.rounding:O(e,0,8),i=R(t=T(new o(s),n+s.e+1,e),!1,n+t.e+1)),s.isNeg()&&!s.isZero()?"-"+i:i},S.toFraction=function(n){var e,i,t,r,s,o,u,c,h,l,d,g,p=this,w=p.d,v=p.constructor;if(!w)return new v(p);if(h=i=new v(1),t=c=new v(0),o=(s=(e=new v(t)).e=_(w)-p.e-1)%7,e.d[0]=m(10,o<0?7+o:o),null==n)n=s>0?e:h;else{if(!(u=new v(n)).isInt()||u.lt(h))throw Error(a+u);n=u.gt(e)?s>0?e:h:u}for(f=!1,u=new v(M(w)),l=v.precision,v.precision=s=7*w.length*2;d=F(u,e,0,1,1),1!=(r=i.plus(d.times(t))).cmp(n);)i=t,t=r,r=h,h=c.plus(d.times(r)),c=r,r=e,e=u.minus(d.times(r)),u=r;return r=F(n.minus(i),t,0,1,1),c=c.plus(r.times(h)),i=i.plus(r.times(t)),c.s=h.s=p.s,g=F(h,t,s,1).minus(p).abs().cmp(F(c,i,s,1).minus(p).abs())<1?[h,t]:[c,i],v.precision=l,f=!0,g},S.toHexadecimal=S.toHex=function(n,e){return J(this,16,n,e)},S.toNearest=function(n,e){var i=this,t=i.constructor;if(i=new t(i),null==n){if(!i.d)return i;n=new t(1),e=t.rounding}else{if(n=new t(n),void 0===e?e=t.rounding:O(e,0,8),!i.d)return n.s?i:n;if(!n.d)return n.s&&(n.s=i.s),n}return n.d[0]?(f=!1,i=F(i,n,0,e,1).times(n),f=!0,T(i)):(n.s=i.s,i=n),i},S.toNumber=function(){return+this},S.toOctal=function(n,e){return J(this,8,n,e)},S.toPower=S.pow=function(n){var e,i,t,r,s,o,u=this,c=u.constructor,h=+(n=new c(n));if(!(u.d&&n.d&&u.d[0]&&n.d[0]))return new c(m(+u,h));if((u=new c(u)).eq(1))return u;if(t=c.precision,s=c.rounding,n.eq(1))return T(u,t,s);if((e=p(n.e/7))>=n.d.length-1&&(i=h<0?-h:h)<=9007199254740991)return r=I(c,u,i,t),n.s<0?new c(1).div(r):T(r,t,s);if((o=u.s)<0){if(e<n.d.length-1)return new c(NaN);if(1&n.d[e]||(o=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=o,u}return(e=0!=(i=m(+u,h))&&isFinite(i)?new c(i+"").e:p(h*(Math.log("0."+M(u.d))/Math.LN10+u.e+1)))>c.maxE+1||e<c.minE-1?new c(e>0?o/0:0):(f=!1,c.rounding=u.s=1,i=Math.min(12,(e+"").length),(r=L(n.times($(u,t+i)),t)).d&&q((r=T(r,t+5,1)).d,t,s)&&(e=t+10,+M((r=T(L(n.times($(u,e+i)),e),e+5,1)).d).slice(t+1,t+15)+1==1e14&&(r=T(r,t+1,0))),r.s=o,f=!0,c.rounding=s,T(r,t,s))},S.toPrecision=function(n,e){var i,t=this,s=t.constructor;return void 0===n?i=R(t,t.e<=s.toExpNeg||t.e>=s.toExpPos):(O(n,1,r),void 0===e?e=s.rounding:O(e,0,8),i=R(t=T(new s(t),n,e),n<=t.e||t.e<=s.toExpNeg,n)),t.isNeg()&&!t.isZero()?"-"+i:i},S.toSignificantDigits=S.toSD=function(n,e){var i=this.constructor;return void 0===n?(n=i.precision,e=i.rounding):(O(n,1,r),void 0===e?e=i.rounding:O(e,0,8)),T(new i(this),n,e)},S.toString=function(){var n=this,e=n.constructor,i=R(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+i:i},S.truncated=S.trunc=function(){return T(new this.constructor(this),this.e+1,1)},S.valueOf=S.toJSON=function(){var n=this,e=n.constructor,i=R(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+i:i};var F=function(){function n(n,e,i){var t,r=0,s=n.length;for(n=n.slice();s--;)t=n[s]*e+r,n[s]=t%i|0,r=t/i|0;return r&&n.unshift(r),n}function i(n,e,i,t){var r,s;if(i!=t)s=i>t?1:-1;else for(r=s=0;r<i;r++)if(n[r]!=e[r]){s=n[r]>e[r]?1:-1;break}return s}function t(n,e,i,t){for(var r=0;i--;)n[i]-=r,r=n[i]<e[i]?1:0,n[i]=r*t+n[i]-e[i];for(;!n[0]&&n.length>1;)n.shift()}return function(r,s,o,u,c,f){var h,a,l,d,g,m,w,v,N,b,y,x,S,M,O,q,D,F,R,U,A=r.constructor,P=r.s==s.s?1:-1,_=r.d,Z=s.d;if(!(_&&_[0]&&Z&&Z[0]))return new A(r.s&&s.s&&(_?!Z||_[0]!=Z[0]:Z)?_&&0==_[0]||!Z?0*P:P/0:NaN);for(f?(g=1,a=r.e-s.e):(f=E,g=7,a=p(r.e/g)-p(s.e/g)),R=Z.length,D=_.length,b=(N=new A(P)).d=[],l=0;Z[l]==(_[l]||0);l++);if(Z[l]>(_[l]||0)&&a--,null==o?(M=o=A.precision,u=A.rounding):M=c?o+(r.e-s.e)+1:o,M<0)b.push(1),m=!0;else{if(M=M/g+2|0,l=0,1==R){for(d=0,Z=Z[0],M++;(l<D||d)&&M--;l++)O=d*f+(_[l]||0),b[l]=O/Z|0,d=O%Z|0;m=d||l<D}else{for((d=f/(Z[0]+1)|0)>1&&(Z=n(Z,d,f),_=n(_,d,f),R=Z.length,D=_.length),q=R,x=(y=_.slice(0,R)).length;x<R;)y[x++]=0;(U=Z.slice()).unshift(0),F=Z[0],Z[1]>=f/2&&++F;do{d=0,(h=i(Z,y,R,x))<0?(S=y[0],R!=x&&(S=S*f+(y[1]||0)),(d=S/F|0)>1?(d>=f&&(d=f-1),1==(h=i(w=n(Z,d,f),y,v=w.length,x=y.length))&&(d--,t(w,R<v?U:Z,v,f))):(0==d&&(h=d=1),w=Z.slice()),(v=w.length)<x&&w.unshift(0),t(y,w,x,f),-1==h&&(h=i(Z,y,R,x=y.length))<1&&(d++,t(y,R<x?U:Z,x,f)),x=y.length):0===h&&(d++,y=[0]),b[l++]=d,h&&y[0]?y[x++]=_[q]||0:(y=[_[q]],x=1)}while((q++<D||void 0!==y[0])&&M--);m=void 0!==y[0]}b[0]||b.shift()}if(1==g)N.e=a,e=m;else{for(l=1,d=b[0];d>=10;d/=10)l++;N.e=l+a*g-1,T(N,c?o+N.e+1:o,u,m)}return N}}();function T(n,e,i,t){var r,s,o,u,c,h,a,l,d,g=n.constructor;n:if(null!=e){if(!(l=n.d))return n;for(r=1,u=l[0];u>=10;u/=10)r++;if((s=e-r)<0)s+=7,o=e,c=(a=l[d=0])/m(10,r-o-1)%10|0;else if((d=Math.ceil((s+1)/7))>=(u=l.length)){if(!t)break n;for(;u++<=d;)l.push(0);a=c=0,r=1,o=(s%=7)-7+1}else{for(a=u=l[d],r=1;u>=10;u/=10)r++;c=(o=(s%=7)-7+r)<0?0:a/m(10,r-o-1)%10|0}if(t=t||e<0||void 0!==l[d+1]||(o<0?a:a%m(10,r-o-1)),h=i<4?(c||t)&&(0==i||i==(n.s<0?3:2)):c>5||5==c&&(4==i||t||6==i&&(s>0?o>0?a/m(10,r-o):0:l[d-1])%10&1||i==(n.s<0?8:7)),e<1||!l[0])return l.length=0,h?(e-=n.e+1,l[0]=m(10,(7-e%7)%7),n.e=-e||0):l[0]=n.e=0,n;if(0==s?(l.length=d,u=1,d--):(l.length=d+1,u=m(10,7-s),l[d]=o>0?(a/m(10,r-o)%m(10,o)|0)*u:0),h)for(;;){if(0==d){for(s=1,o=l[0];o>=10;o/=10)s++;for(o=l[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(n.e++,l[0]==E&&(l[0]=1));break}if(l[d]+=u,l[d]!=E)break;l[d--]=0,u=1}for(s=l.length;0===l[--s];)l.pop()}return f&&(n.e>g.maxE?(n.d=null,n.e=NaN):n.e<g.minE&&(n.e=0,n.d=[0])),n}function R(n,e,i){if(!n.isFinite())return B(n);var t,r=n.e,s=M(n.d),o=s.length;return e?(i&&(t=i-o)>0?s=s.charAt(0)+"."+s.slice(1)+Z(t):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(n.e<0?"e":"e+")+n.e):r<0?(s="0."+Z(-r-1)+s,i&&(t=i-o)>0&&(s+=Z(t))):r>=o?(s+=Z(r+1-o),i&&(t=i-r-1)>0&&(s=s+"."+Z(t))):((t=r+1)<o&&(s=s.slice(0,t)+"."+s.slice(t)),i&&(t=i-o)>0&&(r+1===o&&(s+="."),s+=Z(t))),s}function U(n,e){var i=n[0];for(e*=7;i>=10;i/=10)e++;return e}function A(n,e,i){if(e>y)throw f=!0,i&&(n.precision=i),Error(l);return T(new n(o),e,1,!0)}function P(n,e,i){if(e>x)throw Error(l);return T(new n(u),e,i,!0)}function _(n){var e=n.length-1,i=7*e+1;if(e=n[e]){for(;e%10==0;e/=10)i--;for(e=n[0];e>=10;e/=10)i++}return i}function Z(n){for(var e="";n--;)e+="0";return e}function I(n,e,i,t){var r,s=new n(1),o=Math.ceil(t/7+4);for(f=!1;;){if(i%2&&z((s=s.times(e)).d,o)&&(r=!0),0===(i=p(i/2))){i=s.d.length-1,r&&0===s.d[i]&&++s.d[i];break}z((e=e.times(e)).d,o)}return f=!0,s}function k(n){return 1&n.d[n.d.length-1]}function C(n,e,i){for(var t,r,s=new n(e[0]),o=0;++o<e.length;){if(!(r=new n(e[o])).s){s=r;break}((t=s.cmp(r))===i||0===t&&s.s===i)&&(s=r)}return s}function L(n,e){var i,t,r,s,o,u,c,h=0,a=0,l=0,d=n.constructor,g=d.rounding,p=d.precision;if(!n.d||!n.d[0]||n.e>17)return new d(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(null==e?(f=!1,c=p):c=e,u=new d(.03125);n.e>-2;)n=n.times(u),l+=5;for(c+=t=Math.log(m(2,l))/Math.LN10*2+5|0,i=s=o=new d(1),d.precision=c;;){if(s=T(s.times(n),c,1),i=i.times(++a),M((u=o.plus(F(s,i,c,1))).d).slice(0,c)===M(o.d).slice(0,c)){for(r=l;r--;)o=T(o.times(o),c,1);if(null!=e)return d.precision=p,o;if(!(h<3&&q(o.d,c-t,g,h)))return T(o,d.precision=p,g,f=!0);d.precision=c+=10,i=s=u=new d(1),a=0,h++}o=u}}function $(n,e){var i,t,r,s,o,u,c,h,a,l,d,g=1,p=n,m=p.d,w=p.constructor,v=w.rounding,N=w.precision;if(p.s<0||!m||!m[0]||!p.e&&1==m[0]&&1==m.length)return new w(m&&!m[0]?-1/0:1!=p.s?NaN:m?0:p);if(null==e?(f=!1,a=N):a=e,w.precision=a+=10,t=(i=M(m)).charAt(0),!(Math.abs(s=p.e)<15e14))return h=A(w,a+2,N).times(s+""),p=$(new w(t+"."+i.slice(1)),a-10).plus(h),w.precision=N,null==e?T(p,N,v,f=!0):p;for(;t<7&&1!=t||1==t&&i.charAt(1)>3;)t=(i=M((p=p.times(n)).d)).charAt(0),g++;for(s=p.e,t>1?(p=new w("0."+i),s++):p=new w(t+"."+i.slice(1)),l=p,c=o=p=F(p.minus(1),p.plus(1),a,1),d=T(p.times(p),a,1),r=3;;){if(o=T(o.times(d),a,1),M((h=c.plus(F(o,new w(r),a,1))).d).slice(0,a)===M(c.d).slice(0,a)){if(c=c.times(2),0!==s&&(c=c.plus(A(w,a+2,N).times(s+""))),c=F(c,new w(g),a,1),null!=e)return w.precision=N,c;if(!q(c.d,a-10,v,u))return T(c,w.precision=N,v,f=!0);w.precision=a+=10,h=o=p=F(l.minus(1),l.plus(1),a,1),d=T(p.times(p),a,1),r=u=1}c=h,r+=2}}function B(n){return String(n.s*n.s/0)}function H(n,e){var i,t,r;for((i=e.indexOf("."))>-1&&(e=e.replace(".","")),(t=e.search(/e/i))>0?(i<0&&(i=t),i+=+e.slice(t+1),e=e.substring(0,t)):i<0&&(i=e.length),t=0;48===e.charCodeAt(t);t++);for(r=e.length;48===e.charCodeAt(r-1);--r);if(e=e.slice(t,r)){if(r-=t,n.e=i=i-t-1,n.d=[],t=(i+1)%7,i<0&&(t+=7),t<r){for(t&&n.d.push(+e.slice(0,t)),r-=7;t<r;)n.d.push(+e.slice(t,t+=7));t=7-(e=e.slice(t)).length}else t-=r;for(;t--;)e+="0";n.d.push(+e),f&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function j(n,e){var i,t,r,s,o,u,c,h,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),b.test(e))return H(n,e)}else if("Infinity"===e||"NaN"===e)return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(v.test(e))i=16,e=e.toLowerCase();else if(w.test(e))i=2;else{if(!N.test(e))throw Error(a+e);i=8}for((s=e.search(/p/i))>0?(c=+e.slice(s+1),e=e.substring(2,s)):e=e.slice(2),o=(s=e.indexOf("."))>=0,t=n.constructor,o&&(s=(u=(e=e.replace(".","")).length)-s,r=I(t,new t(i),s,2*s)),s=l=(h=D(e,i,E)).length-1;0===h[s];--s)h.pop();return s<0?new t(0*n.s):(n.e=U(h,l),n.d=h,f=!1,o&&(n=F(n,r,4*u)),c&&(n=n.times(Math.abs(c)<54?m(2,c):In.pow(2,c))),f=!0,n)}function V(n,e,i,t,r){var s,o,u,c,h=n.precision,a=Math.ceil(h/7);for(f=!1,c=i.times(i),u=new n(t);;){if(o=F(u.times(c),new n(e++*e++),h,1),u=r?t.plus(o):t.minus(o),t=F(o.times(c),new n(e++*e++),h,1),void 0!==(o=u.plus(t)).d[a]){for(s=a;o.d[s]===u.d[s]&&s--;);if(-1==s)break}s=u,u=t,t=o,o=s}return f=!0,o.d.length=a+1,o}function W(n,e){for(var i=n;--e;)i*=n;return i}function G(n,e){var t,r=e.s<0,s=P(n,n.precision,1),o=s.times(.5);if((e=e.abs()).lte(o))return i=r?4:1,e;if((t=e.divToInt(s)).isZero())i=r?3:2;else{if((e=e.minus(t.times(s))).lte(o))return i=k(t)?r?2:3:r?4:1,e;i=k(t)?r?1:4:r?3:2}return e.minus(s).abs()}function J(n,i,t,o){var u,c,f,h,a,l,d,g,p,m=n.constructor,w=void 0!==t;if(w?(O(t,1,r),void 0===o?o=m.rounding:O(o,0,8)):(t=m.precision,o=m.rounding),n.isFinite()){for(w?(u=2,16==i?t=4*t-3:8==i&&(t=3*t-2)):u=i,(f=(d=R(n)).indexOf("."))>=0&&(d=d.replace(".",""),(p=new m(1)).e=d.length-f,p.d=D(R(p),10,u),p.e=p.d.length),c=a=(g=D(d,10,u)).length;0==g[--a];)g.pop();if(g[0]){if(f<0?c--:((n=new m(n)).d=g,n.e=c,g=(n=F(n,p,t,o,0,u)).d,c=n.e,l=e),f=g[t],h=u/2,l=l||void 0!==g[t+1],l=o<4?(void 0!==f||l)&&(0===o||o===(n.s<0?3:2)):f>h||f===h&&(4===o||l||6===o&&1&g[t-1]||o===(n.s<0?8:7)),g.length=t,l)for(;++g[--t]>u-1;)g[t]=0,t||(++c,g.unshift(1));for(a=g.length;!g[a-1];--a);for(f=0,d="";f<a;f++)d+=s.charAt(g[f]);if(w){if(a>1)if(16==i||8==i){for(f=16==i?4:3,--a;a%f;a++)d+="0";for(a=(g=D(d,u,i)).length;!g[a-1];--a);for(f=1,d="1.";f<a;f++)d+=s.charAt(g[f])}else d=d.charAt(0)+"."+d.slice(1);d=d+(c<0?"p":"p+")+c}else if(c<0){for(;++c;)d="0"+d;d="0."+d}else if(++c>a)for(c-=a;c--;)d+="0";else c<a&&(d=d.slice(0,c)+"."+d.slice(c))}else d=w?"0p+0":"0";d=(16==i?"0x":2==i?"0b":8==i?"0o":"")+d}else d=B(n);return n.s<0?"-"+d:d}function z(n,e){if(n.length>e)return n.length=e,!0}function K(n){return new this(n).abs()}function Q(n){return new this(n).acos()}function X(n){return new this(n).acosh()}function Y(n,e){return new this(n).plus(e)}function nn(n){return new this(n).asin()}function en(n){return new this(n).asinh()}function tn(n){return new this(n).atan()}function rn(n){return new this(n).atanh()}function sn(n,e){n=new this(n),e=new this(e);var i,t=this.precision,r=this.rounding,s=t+4;return n.s&&e.s?n.d||e.d?!e.d||n.isZero()?(i=e.s<0?P(this,t,r):new this(0)).s=n.s:!n.d||e.isZero()?(i=P(this,s,1).times(.5)).s=n.s:e.s<0?(this.precision=s,this.rounding=1,i=this.atan(F(n,e,s,1)),e=P(this,s,1),this.precision=t,this.rounding=r,i=n.s<0?i.minus(e):i.plus(e)):i=this.atan(F(n,e,s,1)):(i=P(this,s,1).times(e.s>0?.25:.75)).s=n.s:i=new this(NaN),i}function on(n){return new this(n).cbrt()}function un(n){return T(n=new this(n),n.e+1,2)}function cn(n,e,i){return new this(n).clamp(e,i)}function fn(n){if(!n||"object"!=typeof n)throw Error(h+"Object expected");var e,i,s,o=!0===n.defaults,u=["precision",1,r,"rounding",0,8,"toExpNeg",-9e15,0,"toExpPos",0,t,"maxE",0,t,"minE",-9e15,0,"modulo",0,9];for(e=0;e<u.length;e+=3)if(i=u[e],o&&(this[i]=c[i]),void 0!==(s=n[i])){if(!(p(s)===s&&s>=u[e+1]&&s<=u[e+2]))throw Error(a+i+": "+s);this[i]=s}if(i="crypto",o&&(this[i]=c[i]),void 0!==(s=n[i])){if(!0!==s&&!1!==s&&0!==s&&1!==s)throw Error(a+i+": "+s);if(s){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(d);this[i]=!0}else this[i]=!1}return this}function hn(n){return new this(n).cos()}function an(n){return new this(n).cosh()}function ln(n,e){return new this(n).div(e)}function dn(n){return new this(n).exp()}function gn(n){return T(n=new this(n),n.e+1,3)}function pn(){var n,e,i=new this(0);for(f=!1,n=0;n<arguments.length;)if((e=new this(arguments[n++])).d)i.d&&(i=i.plus(e.times(e)));else{if(e.s)return f=!0,new this(1/0);i=e}return f=!0,i.sqrt()}function mn(n){return n instanceof In||n&&n.toStringTag===g||!1}function wn(n){return new this(n).ln()}function vn(n,e){return new this(n).log(e)}function Nn(n){return new this(n).log(2)}function bn(n){return new this(n).log(10)}function En(){return C(this,arguments,-1)}function yn(){return C(this,arguments,1)}function xn(n,e){return new this(n).mod(e)}function Sn(n,e){return new this(n).mul(e)}function Mn(n,e){return new this(n).pow(e)}function On(n){var e,i,t,s,o=0,u=new this(1),c=[];if(void 0===n?n=this.precision:O(n,1,r),t=Math.ceil(n/7),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(t));o<t;)(s=e[o])>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:c[o++]=s%1e7;else{if(!crypto.randomBytes)throw Error(d);for(e=crypto.randomBytes(t*=4);o<t;)(s=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((127&e[o+3])<<24))>=214e7?crypto.randomBytes(4).copy(e,o):(c.push(s%1e7),o+=4);o=t/4}else for(;o<t;)c[o++]=1e7*Math.random()|0;for(n%=7,(t=c[--o])&&n&&(s=m(10,7-n),c[o]=(t/s|0)*s);0===c[o];o--)c.pop();if(o<0)i=0,c=[0];else{for(i=-1;0===c[0];i-=7)c.shift();for(t=1,s=c[0];s>=10;s/=10)t++;t<7&&(i-=7-t)}return u.e=i,u.d=c,u}function qn(n){return T(n=new this(n),n.e+1,this.rounding)}function Dn(n){return(n=new this(n)).d?n.d[0]?n.s:0*n.s:n.s||NaN}function Fn(n){return new this(n).sin()}function Tn(n){return new this(n).sinh()}function Rn(n){return new this(n).sqrt()}function Un(n,e){return new this(n).sub(e)}function An(){var n=0,e=arguments,i=new this(e[n]);for(f=!1;i.s&&++n<e.length;)i=i.plus(e[n]);return f=!0,T(i,this.precision,this.rounding)}function Pn(n){return new this(n).tan()}function _n(n){return new this(n).tanh()}function Zn(n){return T(n=new this(n),n.e+1,1)}S[Symbol.for("nodejs.util.inspect.custom")]=S.toString,S[Symbol.toStringTag]="Decimal";var In=S.constructor=function n(e){var i,t,r;function s(n){var e,i,t,r=this;if(!(r instanceof s))return new s(n);if(r.constructor=s,mn(n))return r.s=n.s,void(f?!n.d||n.e>s.maxE?(r.e=NaN,r.d=null):n.e<s.minE?(r.e=0,r.d=[0]):(r.e=n.e,r.d=n.d.slice()):(r.e=n.e,r.d=n.d?n.d.slice():n.d));if("number"===(t=typeof n)){if(0===n)return r.s=1/n<0?-1:1,r.e=0,void(r.d=[0]);if(n<0?(n=-n,r.s=-1):r.s=1,n===~~n&&n<1e7){for(e=0,i=n;i>=10;i/=10)e++;return void(f?e>s.maxE?(r.e=NaN,r.d=null):e<s.minE?(r.e=0,r.d=[0]):(r.e=e,r.d=[n]):(r.e=e,r.d=[n]))}return 0*n!=0?(n||(r.s=NaN),r.e=NaN,void(r.d=null)):H(r,n.toString())}if("string"===t)return 45===(i=n.charCodeAt(0))?(n=n.slice(1),r.s=-1):(43===i&&(n=n.slice(1)),r.s=1),b.test(n)?H(r,n):j(r,n);if("bigint"===t)return n<0?(n=-n,r.s=-1):r.s=1,H(r,n.toString());throw Error(a+n)}if(s.prototype=S,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=fn,s.clone=n,s.isDecimal=mn,s.abs=K,s.acos=Q,s.acosh=X,s.add=Y,s.asin=nn,s.asinh=en,s.atan=tn,s.atanh=rn,s.atan2=sn,s.cbrt=on,s.ceil=un,s.clamp=cn,s.cos=hn,s.cosh=an,s.div=ln,s.exp=dn,s.floor=gn,s.hypot=pn,s.ln=wn,s.log=vn,s.log10=bn,s.log2=Nn,s.max=En,s.min=yn,s.mod=xn,s.mul=Sn,s.pow=Mn,s.random=On,s.round=qn,s.sign=Dn,s.sin=Fn,s.sinh=Tn,s.sqrt=Rn,s.sub=Un,s.sum=An,s.tan=Pn,s.tanh=_n,s.trunc=Zn,void 0===e&&(e={}),e&&!0!==e.defaults)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],i=0;i<r.length;)e.hasOwnProperty(t=r[i++])||(e[t]=this[t]);return s.config(e),s}(c);o=new In(o),u=new In(u);
8
+ */var e,t,i=9e15,r=1e9,s="0123456789abcdef",o="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",u="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",c={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9e15,maxE:i,crypto:!1},f=!0,h="[DecimalError] ",a=h+"Invalid argument: ",l=h+"Precision limit exceeded",d=h+"crypto unavailable",g="[object Decimal]",p=Math.floor,m=Math.pow,w=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,v=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,N=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,b=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,E=1e7,y=o.length-1,x=u.length-1,S={toStringTag:g};function M(n){var e,t,i,r=n.length-1,s="",o=n[0];if(r>0){for(s+=o,e=1;e<r;e++)(t=7-(i=n[e]+"").length)&&(s+=I(t)),s+=i;(t=7-(i=(o=n[e])+"").length)&&(s+=I(t))}else if(0===o)return"0";for(;o%10==0;)o/=10;return s+o}function D(n,e,t){if(n!==~~n||n<e||n>t)throw Error(a+n)}function O(n,e,t,i){var r,s,o,u;for(s=n[0];s>=10;s/=10)--e;return--e<0?(e+=7,r=0):(r=Math.ceil((e+1)/7),e%=7),s=m(10,7-e),u=n[r]%s|0,null==i?e<3?(0==e?u=u/100|0:1==e&&(u=u/10|0),o=t<4&&99999==u||t>3&&49999==u||5e4==u||0==u):o=(t<4&&u+1==s||t>3&&u+1==s/2)&&(n[r+1]/s/100|0)==m(10,e-2)-1||(u==s/2||0==u)&&!(n[r+1]/s/100|0):e<4?(0==e?u=u/1e3|0:1==e?u=u/100|0:2==e&&(u=u/10|0),o=(i||t<4)&&9999==u||!i&&t>3&&4999==u):o=((i||t<4)&&u+1==s||!i&&t>3&&u+1==s/2)&&(n[r+1]/s/1e3|0)==m(10,e-3)-1,o}function q(n,e,t){for(var i,r,o=[0],u=0,c=n.length;u<c;){for(r=o.length;r--;)o[r]*=e;for(o[0]+=s.indexOf(n.charAt(u++)),i=0;i<o.length;i++)o[i]>t-1&&(void 0===o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/t|0,o[i]%=t)}return o.reverse()}S.absoluteValue=S.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),T(n)},S.ceil=function(){return T(new this.constructor(this),this.e+1,2)},S.clampedTo=S.clamp=function(n,e){var t=this,i=t.constructor;if(n=new i(n),e=new i(e),!n.s||!e.s)return new i(NaN);if(n.gt(e))throw Error(a+e);return t.cmp(n)<0?n:t.cmp(e)>0?e:new i(t)},S.comparedTo=S.cmp=function(n){var e,t,i,r,s=this,o=s.d,u=(n=new s.constructor(n)).d,c=s.s,f=n.s;if(!o||!u)return c&&f?c!==f?c:o===u?0:!o^c<0?1:-1:NaN;if(!o[0]||!u[0])return o[0]?c:u[0]?-f:0;if(c!==f)return c;if(s.e!==n.e)return s.e>n.e^c<0?1:-1;for(e=0,t=(i=o.length)<(r=u.length)?i:r;e<t;++e)if(o[e]!==u[e])return o[e]>u[e]^c<0?1:-1;return i===r?0:i>r^c<0?1:-1},S.cosine=S.cos=function(){var n,e,i=this,r=i.constructor;return i.d?i.d[0]?(n=r.precision,e=r.rounding,r.precision=n+Math.max(i.e,i.sd())+7,r.rounding=1,i=function(n,e){var t,i,r;if(e.isZero())return e;i=e.d.length,i<32?r=(1/W(4,t=Math.ceil(i/3))).toString():(t=16,r="2.3283064365386962890625e-10");n.precision+=t,e=V(n,1,e.times(r),new n(1));for(var s=t;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=t,e}(r,G(r,i)),r.precision=n,r.rounding=e,T(2==t||3==t?i.neg():i,n,e,!0)):new r(1):new r(NaN)},S.cubeRoot=S.cbrt=function(){var n,e,t,i,r,s,o,u,c,h,a=this,l=a.constructor;if(!a.isFinite()||a.isZero())return new l(a);for(f=!1,(s=a.s*m(a.s*a,1/3))&&Math.abs(s)!=1/0?i=new l(s.toString()):(t=M(a.d),(s=((n=a.e)-t.length+1)%3)&&(t+=1==s||-2==s?"0":"00"),s=m(t,1/3),n=p((n+1)/3)-(n%3==(n<0?-1:2)),(i=new l(t=s==1/0?"5e"+n:(t=s.toExponential()).slice(0,t.indexOf("e")+1)+n)).s=a.s),o=(n=l.precision)+3;;)if(h=(c=(u=i).times(u).times(u)).plus(a),i=F(h.plus(a).times(u),h.plus(c),o+2,1),M(u.d).slice(0,o)===(t=M(i.d)).slice(0,o)){if("9999"!=(t=t.slice(o-3,o+1))&&(r||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(T(i,n+1,1),e=!i.times(i).times(i).eq(a));break}if(!r&&(T(u,n+1,0),u.times(u).times(u).eq(a))){i=u;break}o+=4,r=1}return f=!0,T(i,n,l.rounding,e)},S.decimalPlaces=S.dp=function(){var n,e=this.d,t=NaN;if(e){if(t=7*((n=e.length-1)-p(this.e/7)),n=e[n])for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t},S.dividedBy=S.div=function(n){return F(this,new this.constructor(n))},S.dividedToIntegerBy=S.divToInt=function(n){var e=this.constructor;return T(F(this,new e(n),0,1,1),e.precision,e.rounding)},S.equals=S.eq=function(n){return 0===this.cmp(n)},S.floor=function(){return T(new this.constructor(this),this.e+1,3)},S.greaterThan=S.gt=function(n){return this.cmp(n)>0},S.greaterThanOrEqualTo=S.gte=function(n){var e=this.cmp(n);return 1==e||0===e},S.hyperbolicCosine=S.cosh=function(){var n,e,t,i,r,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;t=o.precision,i=o.rounding,o.precision=t+Math.max(s.e,s.sd())+4,o.rounding=1,(r=s.d.length)<32?e=(1/W(4,n=Math.ceil(r/3))).toString():(n=16,e="2.3283064365386962890625e-10"),s=V(o,1,s.times(e),new o(1),!0);for(var c,f=n,h=new o(8);f--;)c=s.times(s),s=u.minus(c.times(h.minus(c.times(h))));return T(s,o.precision=t,o.rounding=i,!0)},S.hyperbolicSine=S.sinh=function(){var n,e,t,i,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(e=s.precision,t=s.rounding,s.precision=e+Math.max(r.e,r.sd())+4,s.rounding=1,(i=r.d.length)<3)r=V(s,2,r,r,!0);else{n=(n=1.4*Math.sqrt(i))>16?16:0|n,r=V(s,2,r=r.times(1/W(5,n)),r,!0);for(var o,u=new s(5),c=new s(16),f=new s(20);n--;)o=r.times(r),r=r.times(u.plus(o.times(c.times(o).plus(f))))}return s.precision=e,s.rounding=t,T(r,e,t,!0)},S.hyperbolicTangent=S.tanh=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+7,i.rounding=1,F(t.sinh(),t.cosh(),i.precision=n,i.rounding=e)):new i(t.s)},S.inverseCosine=S.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),i=e.precision,r=e.rounding;return-1!==t?0===t?n.isNeg()?_(e,i,r):new e(0):new e(NaN):n.isZero()?_(e,i+4,r).times(.5):(e.precision=i+6,e.rounding=1,n=new e(1).minus(n).div(n.plus(1)).sqrt().atan(),e.precision=i,e.rounding=r,n.times(2))},S.inverseHyperbolicCosine=S.acosh=function(){var n,e,t=this,i=t.constructor;return t.lte(1)?new i(t.eq(1)?0:NaN):t.isFinite()?(n=i.precision,e=i.rounding,i.precision=n+Math.max(Math.abs(t.e),t.sd())+4,i.rounding=1,f=!1,t=t.times(t).minus(1).sqrt().plus(t),f=!0,i.precision=n,i.rounding=e,t.ln()):new i(t)},S.inverseHyperbolicSine=S.asinh=function(){var n,e,t=this,i=t.constructor;return!t.isFinite()||t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,i.rounding=1,f=!1,t=t.times(t).plus(1).sqrt().plus(t),f=!0,i.precision=n,i.rounding=e,t.ln())},S.inverseHyperbolicTangent=S.atanh=function(){var n,e,t,i,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=s.precision,e=s.rounding,i=r.sd(),Math.max(i,n)<2*-r.e-1?T(new s(r),n,e,!0):(s.precision=t=i-r.e,r=F(r.plus(1),new s(1).minus(r),t+n,1),s.precision=n+4,s.rounding=1,r=r.ln(),s.precision=n,s.rounding=e,r.times(.5))):new s(NaN)},S.inverseSine=S.asin=function(){var n,e,t,i,r=this,s=r.constructor;return r.isZero()?new s(r):(e=r.abs().cmp(1),t=s.precision,i=s.rounding,-1!==e?0===e?((n=_(s,t+4,i).times(.5)).s=r.s,n):new s(NaN):(s.precision=t+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=t,s.rounding=i,r.times(2)))},S.inverseTangent=S.atan=function(){var n,e,t,i,r,s,o,u,c,h=this,a=h.constructor,l=a.precision,d=a.rounding;if(h.isFinite()){if(h.isZero())return new a(h);if(h.abs().eq(1)&&l+4<=x)return(o=_(a,l+4,d).times(.25)).s=h.s,o}else{if(!h.s)return new a(NaN);if(l+4<=x)return(o=_(a,l+4,d).times(.5)).s=h.s,o}for(a.precision=u=l+10,a.rounding=1,n=t=Math.min(28,u/7+2|0);n;--n)h=h.div(h.times(h).plus(1).sqrt().plus(1));for(f=!1,e=Math.ceil(u/7),i=1,c=h.times(h),o=new a(h),r=h;-1!==n;)if(r=r.times(c),s=o.minus(r.div(i+=2)),r=r.times(c),void 0!==(o=s.plus(r.div(i+=2))).d[e])for(n=e;o.d[n]===s.d[n]&&n--;);return t&&(o=o.times(2<<t-1)),f=!0,T(o,a.precision=l,a.rounding=d,!0)},S.isFinite=function(){return!!this.d},S.isInteger=S.isInt=function(){return!!this.d&&p(this.e/7)>this.d.length-2},S.isNaN=function(){return!this.s},S.isNegative=S.isNeg=function(){return this.s<0},S.isPositive=S.isPos=function(){return this.s>0},S.isZero=function(){return!!this.d&&0===this.d[0]},S.lessThan=S.lt=function(n){return this.cmp(n)<0},S.lessThanOrEqualTo=S.lte=function(n){return this.cmp(n)<1},S.logarithm=S.log=function(n){var e,t,i,r,s,o,u,c,h=this,a=h.constructor,l=a.precision,d=a.rounding;if(null==n)n=new a(10),e=!0;else{if(t=(n=new a(n)).d,n.s<0||!t||!t[0]||n.eq(1))return new a(NaN);e=n.eq(10)}if(t=h.d,h.s<0||!t||!t[0]||h.eq(1))return new a(t&&!t[0]?-1/0:1!=h.s?NaN:t?0:1/0);if(e)if(t.length>1)s=!0;else{for(r=t[0];r%10==0;)r/=10;s=1!==r}if(f=!1,o=$(h,u=l+5),i=e?A(a,u+10):$(n,u),O((c=F(o,i,u,1)).d,r=l,d))do{if(o=$(h,u+=10),i=e?A(a,u+10):$(n,u),c=F(o,i,u,1),!s){+M(c.d).slice(r+1,r+15)+1==1e14&&(c=T(c,l+1,0));break}}while(O(c.d,r+=10,d));return f=!0,T(c,l,d)},S.minus=S.sub=function(n){var e,t,i,r,s,o,u,c,h,a,l,d,g=this,m=g.constructor;if(n=new m(n),!g.d||!n.d)return g.s&&n.s?g.d?n.s=-n.s:n=new m(n.d||g.s!==n.s?g:NaN):n=new m(NaN),n;if(g.s!=n.s)return n.s=-n.s,g.plus(n);if(h=g.d,d=n.d,u=m.precision,c=m.rounding,!h[0]||!d[0]){if(d[0])n.s=-n.s;else{if(!h[0])return new m(3===c?-0:0);n=new m(g)}return f?T(n,u,c):n}if(t=p(n.e/7),a=p(g.e/7),h=h.slice(),s=a-t){for((l=s<0)?(e=h,s=-s,o=d.length):(e=d,t=a,o=h.length),s>(i=Math.max(Math.ceil(u/7),o)+2)&&(s=i,e.length=1),e.reverse(),i=s;i--;)e.push(0);e.reverse()}else{for((l=(i=h.length)<(o=d.length))&&(o=i),i=0;i<o;i++)if(h[i]!=d[i]){l=h[i]<d[i];break}s=0}for(l&&(e=h,h=d,d=e,n.s=-n.s),o=h.length,i=d.length-o;i>0;--i)h[o++]=0;for(i=d.length;i>s;){if(h[--i]<d[i]){for(r=i;r&&0===h[--r];)h[r]=E-1;--h[r],h[i]+=E}h[i]-=d[i]}for(;0===h[--o];)h.pop();for(;0===h[0];h.shift())--t;return h[0]?(n.d=h,n.e=U(h,t),f?T(n,u,c):n):new m(3===c?-0:0)},S.modulo=S.mod=function(n){var e,t=this,i=t.constructor;return n=new i(n),!t.d||!n.s||n.d&&!n.d[0]?new i(NaN):!n.d||t.d&&!t.d[0]?T(new i(t),i.precision,i.rounding):(f=!1,9==i.modulo?(e=F(t,n.abs(),0,3,1)).s*=n.s:e=F(t,n,0,i.modulo,1),e=e.times(n),f=!0,t.minus(e))},S.naturalExponential=S.exp=function(){return L(this)},S.naturalLogarithm=S.ln=function(){return $(this)},S.negated=S.neg=function(){var n=new this.constructor(this);return n.s=-n.s,T(n)},S.plus=S.add=function(n){var e,t,i,r,s,o,u,c,h,a,l=this,d=l.constructor;if(n=new d(n),!l.d||!n.d)return l.s&&n.s?l.d||(n=new d(n.d||l.s===n.s?l:NaN)):n=new d(NaN),n;if(l.s!=n.s)return n.s=-n.s,l.minus(n);if(h=l.d,a=n.d,u=d.precision,c=d.rounding,!h[0]||!a[0])return a[0]||(n=new d(l)),f?T(n,u,c):n;if(s=p(l.e/7),i=p(n.e/7),h=h.slice(),r=s-i){for(r<0?(t=h,r=-r,o=a.length):(t=a,i=s,o=h.length),r>(o=(s=Math.ceil(u/7))>o?s+1:o+1)&&(r=o,t.length=1),t.reverse();r--;)t.push(0);t.reverse()}for((o=h.length)-(r=a.length)<0&&(r=o,t=a,a=h,h=t),e=0;r;)e=(h[--r]=h[r]+a[r]+e)/E|0,h[r]%=E;for(e&&(h.unshift(e),++i),o=h.length;0==h[--o];)h.pop();return n.d=h,n.e=U(h,i),f?T(n,u,c):n},S.precision=S.sd=function(n){var e,t=this;if(void 0!==n&&n!==!!n&&1!==n&&0!==n)throw Error(a+n);return t.d?(e=Z(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e},S.round=function(){var n=this,e=n.constructor;return T(new e(n),n.e+1,e.rounding)},S.sine=S.sin=function(){var n,e,i=this,r=i.constructor;return i.isFinite()?i.isZero()?new r(i):(n=r.precision,e=r.rounding,r.precision=n+Math.max(i.e,i.sd())+7,r.rounding=1,i=function(n,e){var t,i=e.d.length;if(i<3)return e.isZero()?e:V(n,2,e,e);t=(t=1.4*Math.sqrt(i))>16?16:0|t,e=e.times(1/W(5,t)),e=V(n,2,e,e);for(var r,s=new n(5),o=new n(16),u=new n(20);t--;)r=e.times(e),e=e.times(s.plus(r.times(o.times(r).minus(u))));return e}(r,G(r,i)),r.precision=n,r.rounding=e,T(t>2?i.neg():i,n,e,!0)):new r(NaN)},S.squareRoot=S.sqrt=function(){var n,e,t,i,r,s,o=this,u=o.d,c=o.e,h=o.s,a=o.constructor;if(1!==h||!u||!u[0])return new a(!h||h<0&&(!u||u[0])?NaN:u?o:1/0);for(f=!1,0==(h=Math.sqrt(+o))||h==1/0?(((e=M(u)).length+c)%2==0&&(e+="0"),h=Math.sqrt(e),c=p((c+1)/2)-(c<0||c%2),i=new a(e=h==1/0?"5e"+c:(e=h.toExponential()).slice(0,e.indexOf("e")+1)+c)):i=new a(h.toString()),t=(c=a.precision)+3;;)if(i=(s=i).plus(F(o,s,t+2,1)).times(.5),M(s.d).slice(0,t)===(e=M(i.d)).slice(0,t)){if("9999"!=(e=e.slice(t-3,t+1))&&(r||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(T(i,c+1,1),n=!i.times(i).eq(o));break}if(!r&&(T(s,c+1,0),s.times(s).eq(o))){i=s;break}t+=4,r=1}return f=!0,T(i,c,a.rounding,n)},S.tangent=S.tan=function(){var n,e,i=this,r=i.constructor;return i.isFinite()?i.isZero()?new r(i):(n=r.precision,e=r.rounding,r.precision=n+10,r.rounding=1,(i=i.sin()).s=1,i=F(i,new r(1).minus(i.times(i)).sqrt(),n+10,0),r.precision=n,r.rounding=e,T(2==t||4==t?i.neg():i,n,e,!0)):new r(NaN)},S.times=S.mul=function(n){var e,t,i,r,s,o,u,c,h,a=this,l=a.constructor,d=a.d,g=(n=new l(n)).d;if(n.s*=a.s,!(d&&d[0]&&g&&g[0]))return new l(!n.s||d&&!d[0]&&!g||g&&!g[0]&&!d?NaN:d&&g?0*n.s:n.s/0);for(t=p(a.e/7)+p(n.e/7),(c=d.length)<(h=g.length)&&(s=d,d=g,g=s,o=c,c=h,h=o),s=[],i=o=c+h;i--;)s.push(0);for(i=h;--i>=0;){for(e=0,r=c+i;r>i;)u=s[r]+g[i]*d[r-i-1]+e,s[r--]=u%E|0,e=u/E|0;s[r]=(s[r]+e)%E|0}for(;!s[--o];)s.pop();return e?++t:s.shift(),n.d=s,n.e=U(s,t),f?T(n,l.precision,l.rounding):n},S.toBinary=function(n,e){return J(this,2,n,e)},S.toDecimalPlaces=S.toDP=function(n,e){var t=this,i=t.constructor;return t=new i(t),void 0===n?t:(D(n,0,r),void 0===e?e=i.rounding:D(e,0,8),T(t,n+t.e+1,e))},S.toExponential=function(n,e){var t,i=this,s=i.constructor;return void 0===n?t=R(i,!0):(D(n,0,r),void 0===e?e=s.rounding:D(e,0,8),t=R(i=T(new s(i),n+1,e),!0,n+1)),i.isNeg()&&!i.isZero()?"-"+t:t},S.toFixed=function(n,e){var t,i,s=this,o=s.constructor;return void 0===n?t=R(s):(D(n,0,r),void 0===e?e=o.rounding:D(e,0,8),t=R(i=T(new o(s),n+s.e+1,e),!1,n+i.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t},S.toFraction=function(n){var e,t,i,r,s,o,u,c,h,l,d,g,p=this,w=p.d,v=p.constructor;if(!w)return new v(p);if(h=t=new v(1),i=c=new v(0),o=(s=(e=new v(i)).e=Z(w)-p.e-1)%7,e.d[0]=m(10,o<0?7+o:o),null==n)n=s>0?e:h;else{if(!(u=new v(n)).isInt()||u.lt(h))throw Error(a+u);n=u.gt(e)?s>0?e:h:u}for(f=!1,u=new v(M(w)),l=v.precision,v.precision=s=7*w.length*2;d=F(u,e,0,1,1),1!=(r=t.plus(d.times(i))).cmp(n);)t=i,i=r,r=h,h=c.plus(d.times(r)),c=r,r=e,e=u.minus(d.times(r)),u=r;return r=F(n.minus(t),i,0,1,1),c=c.plus(r.times(h)),t=t.plus(r.times(i)),c.s=h.s=p.s,g=F(h,i,s,1).minus(p).abs().cmp(F(c,t,s,1).minus(p).abs())<1?[h,i]:[c,t],v.precision=l,f=!0,g},S.toHexadecimal=S.toHex=function(n,e){return J(this,16,n,e)},S.toNearest=function(n,e){var t=this,i=t.constructor;if(t=new i(t),null==n){if(!t.d)return t;n=new i(1),e=i.rounding}else{if(n=new i(n),void 0===e?e=i.rounding:D(e,0,8),!t.d)return n.s?t:n;if(!n.d)return n.s&&(n.s=t.s),n}return n.d[0]?(f=!1,t=F(t,n,0,e,1).times(n),f=!0,T(t)):(n.s=t.s,t=n),t},S.toNumber=function(){return+this},S.toOctal=function(n,e){return J(this,8,n,e)},S.toPower=S.pow=function(n){var e,t,i,r,s,o,u=this,c=u.constructor,h=+(n=new c(n));if(!(u.d&&n.d&&u.d[0]&&n.d[0]))return new c(m(+u,h));if((u=new c(u)).eq(1))return u;if(i=c.precision,s=c.rounding,n.eq(1))return T(u,i,s);if((e=p(n.e/7))>=n.d.length-1&&(t=h<0?-h:h)<=9007199254740991)return r=P(c,u,t,i),n.s<0?new c(1).div(r):T(r,i,s);if((o=u.s)<0){if(e<n.d.length-1)return new c(NaN);if(1&n.d[e]||(o=1),0==u.e&&1==u.d[0]&&1==u.d.length)return u.s=o,u}return(e=0!=(t=m(+u,h))&&isFinite(t)?new c(t+"").e:p(h*(Math.log("0."+M(u.d))/Math.LN10+u.e+1)))>c.maxE+1||e<c.minE-1?new c(e>0?o/0:0):(f=!1,c.rounding=u.s=1,t=Math.min(12,(e+"").length),(r=L(n.times($(u,i+t)),i)).d&&O((r=T(r,i+5,1)).d,i,s)&&(e=i+10,+M((r=T(L(n.times($(u,e+t)),e),e+5,1)).d).slice(i+1,i+15)+1==1e14&&(r=T(r,i+1,0))),r.s=o,f=!0,c.rounding=s,T(r,i,s))},S.toPrecision=function(n,e){var t,i=this,s=i.constructor;return void 0===n?t=R(i,i.e<=s.toExpNeg||i.e>=s.toExpPos):(D(n,1,r),void 0===e?e=s.rounding:D(e,0,8),t=R(i=T(new s(i),n,e),n<=i.e||i.e<=s.toExpNeg,n)),i.isNeg()&&!i.isZero()?"-"+t:t},S.toSignificantDigits=S.toSD=function(n,e){var t=this.constructor;return void 0===n?(n=t.precision,e=t.rounding):(D(n,1,r),void 0===e?e=t.rounding:D(e,0,8)),T(new t(this),n,e)},S.toString=function(){var n=this,e=n.constructor,t=R(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t},S.truncated=S.trunc=function(){return T(new this.constructor(this),this.e+1,1)},S.valueOf=S.toJSON=function(){var n=this,e=n.constructor,t=R(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};var F=function(){function n(n,e,t){var i,r=0,s=n.length;for(n=n.slice();s--;)i=n[s]*e+r,n[s]=i%t|0,r=i/t|0;return r&&n.unshift(r),n}function t(n,e,t,i){var r,s;if(t!=i)s=t>i?1:-1;else for(r=s=0;r<t;r++)if(n[r]!=e[r]){s=n[r]>e[r]?1:-1;break}return s}function i(n,e,t,i){for(var r=0;t--;)n[t]-=r,r=n[t]<e[t]?1:0,n[t]=r*i+n[t]-e[t];for(;!n[0]&&n.length>1;)n.shift()}return function(r,s,o,u,c,f){var h,a,l,d,g,m,w,v,N,b,y,x,S,M,D,O,q,F,R,U,A=r.constructor,_=r.s==s.s?1:-1,Z=r.d,I=s.d;if(!(Z&&Z[0]&&I&&I[0]))return new A(r.s&&s.s&&(Z?!I||Z[0]!=I[0]:I)?Z&&0==Z[0]||!I?0*_:_/0:NaN);for(f?(g=1,a=r.e-s.e):(f=E,g=7,a=p(r.e/g)-p(s.e/g)),R=I.length,q=Z.length,b=(N=new A(_)).d=[],l=0;I[l]==(Z[l]||0);l++);if(I[l]>(Z[l]||0)&&a--,null==o?(M=o=A.precision,u=A.rounding):M=c?o+(r.e-s.e)+1:o,M<0)b.push(1),m=!0;else{if(M=M/g+2|0,l=0,1==R){for(d=0,I=I[0],M++;(l<q||d)&&M--;l++)D=d*f+(Z[l]||0),b[l]=D/I|0,d=D%I|0;m=d||l<q}else{for((d=f/(I[0]+1)|0)>1&&(I=n(I,d,f),Z=n(Z,d,f),R=I.length,q=Z.length),O=R,x=(y=Z.slice(0,R)).length;x<R;)y[x++]=0;(U=I.slice()).unshift(0),F=I[0],I[1]>=f/2&&++F;do{d=0,(h=t(I,y,R,x))<0?(S=y[0],R!=x&&(S=S*f+(y[1]||0)),(d=S/F|0)>1?(d>=f&&(d=f-1),1==(h=t(w=n(I,d,f),y,v=w.length,x=y.length))&&(d--,i(w,R<v?U:I,v,f))):(0==d&&(h=d=1),w=I.slice()),(v=w.length)<x&&w.unshift(0),i(y,w,x,f),-1==h&&(h=t(I,y,R,x=y.length))<1&&(d++,i(y,R<x?U:I,x,f)),x=y.length):0===h&&(d++,y=[0]),b[l++]=d,h&&y[0]?y[x++]=Z[O]||0:(y=[Z[O]],x=1)}while((O++<q||void 0!==y[0])&&M--);m=void 0!==y[0]}b[0]||b.shift()}if(1==g)N.e=a,e=m;else{for(l=1,d=b[0];d>=10;d/=10)l++;N.e=l+a*g-1,T(N,c?o+N.e+1:o,u,m)}return N}}();function T(n,e,t,i){var r,s,o,u,c,h,a,l,d,g=n.constructor;n:if(null!=e){if(!(l=n.d))return n;for(r=1,u=l[0];u>=10;u/=10)r++;if((s=e-r)<0)s+=7,o=e,c=(a=l[d=0])/m(10,r-o-1)%10|0;else if((d=Math.ceil((s+1)/7))>=(u=l.length)){if(!i)break n;for(;u++<=d;)l.push(0);a=c=0,r=1,o=(s%=7)-7+1}else{for(a=u=l[d],r=1;u>=10;u/=10)r++;c=(o=(s%=7)-7+r)<0?0:a/m(10,r-o-1)%10|0}if(i=i||e<0||void 0!==l[d+1]||(o<0?a:a%m(10,r-o-1)),h=t<4?(c||i)&&(0==t||t==(n.s<0?3:2)):c>5||5==c&&(4==t||i||6==t&&(s>0?o>0?a/m(10,r-o):0:l[d-1])%10&1||t==(n.s<0?8:7)),e<1||!l[0])return l.length=0,h?(e-=n.e+1,l[0]=m(10,(7-e%7)%7),n.e=-e||0):l[0]=n.e=0,n;if(0==s?(l.length=d,u=1,d--):(l.length=d+1,u=m(10,7-s),l[d]=o>0?(a/m(10,r-o)%m(10,o)|0)*u:0),h)for(;;){if(0==d){for(s=1,o=l[0];o>=10;o/=10)s++;for(o=l[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(n.e++,l[0]==E&&(l[0]=1));break}if(l[d]+=u,l[d]!=E)break;l[d--]=0,u=1}for(s=l.length;0===l[--s];)l.pop()}return f&&(n.e>g.maxE?(n.d=null,n.e=NaN):n.e<g.minE&&(n.e=0,n.d=[0])),n}function R(n,e,t){if(!n.isFinite())return B(n);var i,r=n.e,s=M(n.d),o=s.length;return e?(t&&(i=t-o)>0?s=s.charAt(0)+"."+s.slice(1)+I(i):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(n.e<0?"e":"e+")+n.e):r<0?(s="0."+I(-r-1)+s,t&&(i=t-o)>0&&(s+=I(i))):r>=o?(s+=I(r+1-o),t&&(i=t-r-1)>0&&(s=s+"."+I(i))):((i=r+1)<o&&(s=s.slice(0,i)+"."+s.slice(i)),t&&(i=t-o)>0&&(r+1===o&&(s+="."),s+=I(i))),s}function U(n,e){var t=n[0];for(e*=7;t>=10;t/=10)e++;return e}function A(n,e,t){if(e>y)throw f=!0,t&&(n.precision=t),Error(l);return T(new n(o),e,1,!0)}function _(n,e,t){if(e>x)throw Error(l);return T(new n(u),e,t,!0)}function Z(n){var e=n.length-1,t=7*e+1;if(e=n[e]){for(;e%10==0;e/=10)t--;for(e=n[0];e>=10;e/=10)t++}return t}function I(n){for(var e="";n--;)e+="0";return e}function P(n,e,t,i){var r,s=new n(1),o=Math.ceil(i/7+4);for(f=!1;;){if(t%2&&z((s=s.times(e)).d,o)&&(r=!0),0===(t=p(t/2))){t=s.d.length-1,r&&0===s.d[t]&&++s.d[t];break}z((e=e.times(e)).d,o)}return f=!0,s}function k(n){return 1&n.d[n.d.length-1]}function C(n,e,t){for(var i,r,s=new n(e[0]),o=0;++o<e.length;){if(!(r=new n(e[o])).s){s=r;break}((i=s.cmp(r))===t||0===i&&s.s===t)&&(s=r)}return s}function L(n,e){var t,i,r,s,o,u,c,h=0,a=0,l=0,d=n.constructor,g=d.rounding,p=d.precision;if(!n.d||!n.d[0]||n.e>17)return new d(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(null==e?(f=!1,c=p):c=e,u=new d(.03125);n.e>-2;)n=n.times(u),l+=5;for(c+=i=Math.log(m(2,l))/Math.LN10*2+5|0,t=s=o=new d(1),d.precision=c;;){if(s=T(s.times(n),c,1),t=t.times(++a),M((u=o.plus(F(s,t,c,1))).d).slice(0,c)===M(o.d).slice(0,c)){for(r=l;r--;)o=T(o.times(o),c,1);if(null!=e)return d.precision=p,o;if(!(h<3&&O(o.d,c-i,g,h)))return T(o,d.precision=p,g,f=!0);d.precision=c+=10,t=s=u=new d(1),a=0,h++}o=u}}function $(n,e){var t,i,r,s,o,u,c,h,a,l,d,g=1,p=n,m=p.d,w=p.constructor,v=w.rounding,N=w.precision;if(p.s<0||!m||!m[0]||!p.e&&1==m[0]&&1==m.length)return new w(m&&!m[0]?-1/0:1!=p.s?NaN:m?0:p);if(null==e?(f=!1,a=N):a=e,w.precision=a+=10,i=(t=M(m)).charAt(0),!(Math.abs(s=p.e)<15e14))return h=A(w,a+2,N).times(s+""),p=$(new w(i+"."+t.slice(1)),a-10).plus(h),w.precision=N,null==e?T(p,N,v,f=!0):p;for(;i<7&&1!=i||1==i&&t.charAt(1)>3;)i=(t=M((p=p.times(n)).d)).charAt(0),g++;for(s=p.e,i>1?(p=new w("0."+t),s++):p=new w(i+"."+t.slice(1)),l=p,c=o=p=F(p.minus(1),p.plus(1),a,1),d=T(p.times(p),a,1),r=3;;){if(o=T(o.times(d),a,1),M((h=c.plus(F(o,new w(r),a,1))).d).slice(0,a)===M(c.d).slice(0,a)){if(c=c.times(2),0!==s&&(c=c.plus(A(w,a+2,N).times(s+""))),c=F(c,new w(g),a,1),null!=e)return w.precision=N,c;if(!O(c.d,a-10,v,u))return T(c,w.precision=N,v,f=!0);w.precision=a+=10,h=o=p=F(l.minus(1),l.plus(1),a,1),d=T(p.times(p),a,1),r=u=1}c=h,r+=2}}function B(n){return String(n.s*n.s/0)}function H(n,e){var t,i,r;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(t<0&&(t=i),t+=+e.slice(i+1),e=e.substring(0,i)):t<0&&(t=e.length),i=0;48===e.charCodeAt(i);i++);for(r=e.length;48===e.charCodeAt(r-1);--r);if(e=e.slice(i,r)){if(r-=i,n.e=t=t-i-1,n.d=[],i=(t+1)%7,t<0&&(i+=7),i<r){for(i&&n.d.push(+e.slice(0,i)),r-=7;i<r;)n.d.push(+e.slice(i,i+=7));i=7-(e=e.slice(i)).length}else i-=r;for(;i--;)e+="0";n.d.push(+e),f&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function j(n,e){var t,i,r,s,o,u,c,h,l;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),b.test(e))return H(n,e)}else if("Infinity"===e||"NaN"===e)return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(v.test(e))t=16,e=e.toLowerCase();else if(w.test(e))t=2;else{if(!N.test(e))throw Error(a+e);t=8}for((s=e.search(/p/i))>0?(c=+e.slice(s+1),e=e.substring(2,s)):e=e.slice(2),o=(s=e.indexOf("."))>=0,i=n.constructor,o&&(s=(u=(e=e.replace(".","")).length)-s,r=P(i,new i(t),s,2*s)),s=l=(h=q(e,t,E)).length-1;0===h[s];--s)h.pop();return s<0?new i(0*n.s):(n.e=U(h,l),n.d=h,f=!1,o&&(n=F(n,r,4*u)),c&&(n=n.times(Math.abs(c)<54?m(2,c):Pn.pow(2,c))),f=!0,n)}function V(n,e,t,i,r){var s,o,u,c,h=n.precision,a=Math.ceil(h/7);for(f=!1,c=t.times(t),u=new n(i);;){if(o=F(u.times(c),new n(e++*e++),h,1),u=r?i.plus(o):i.minus(o),i=F(o.times(c),new n(e++*e++),h,1),void 0!==(o=u.plus(i)).d[a]){for(s=a;o.d[s]===u.d[s]&&s--;);if(-1==s)break}s=u,u=i,i=o,o=s}return f=!0,o.d.length=a+1,o}function W(n,e){for(var t=n;--e;)t*=n;return t}function G(n,e){var i,r=e.s<0,s=_(n,n.precision,1),o=s.times(.5);if((e=e.abs()).lte(o))return t=r?4:1,e;if((i=e.divToInt(s)).isZero())t=r?3:2;else{if((e=e.minus(i.times(s))).lte(o))return t=k(i)?r?2:3:r?4:1,e;t=k(i)?r?1:4:r?3:2}return e.minus(s).abs()}function J(n,t,i,o){var u,c,f,h,a,l,d,g,p,m=n.constructor,w=void 0!==i;if(w?(D(i,1,r),void 0===o?o=m.rounding:D(o,0,8)):(i=m.precision,o=m.rounding),n.isFinite()){for(w?(u=2,16==t?i=4*i-3:8==t&&(i=3*i-2)):u=t,(f=(d=R(n)).indexOf("."))>=0&&(d=d.replace(".",""),(p=new m(1)).e=d.length-f,p.d=q(R(p),10,u),p.e=p.d.length),c=a=(g=q(d,10,u)).length;0==g[--a];)g.pop();if(g[0]){if(f<0?c--:((n=new m(n)).d=g,n.e=c,g=(n=F(n,p,i,o,0,u)).d,c=n.e,l=e),f=g[i],h=u/2,l=l||void 0!==g[i+1],l=o<4?(void 0!==f||l)&&(0===o||o===(n.s<0?3:2)):f>h||f===h&&(4===o||l||6===o&&1&g[i-1]||o===(n.s<0?8:7)),g.length=i,l)for(;++g[--i]>u-1;)g[i]=0,i||(++c,g.unshift(1));for(a=g.length;!g[a-1];--a);for(f=0,d="";f<a;f++)d+=s.charAt(g[f]);if(w){if(a>1)if(16==t||8==t){for(f=16==t?4:3,--a;a%f;a++)d+="0";for(a=(g=q(d,u,t)).length;!g[a-1];--a);for(f=1,d="1.";f<a;f++)d+=s.charAt(g[f])}else d=d.charAt(0)+"."+d.slice(1);d=d+(c<0?"p":"p+")+c}else if(c<0){for(;++c;)d="0"+d;d="0."+d}else if(++c>a)for(c-=a;c--;)d+="0";else c<a&&(d=d.slice(0,c)+"."+d.slice(c))}else d=w?"0p+0":"0";d=(16==t?"0x":2==t?"0b":8==t?"0o":"")+d}else d=B(n);return n.s<0?"-"+d:d}function z(n,e){if(n.length>e)return n.length=e,!0}function K(n){return new this(n).abs()}function Q(n){return new this(n).acos()}function X(n){return new this(n).acosh()}function Y(n,e){return new this(n).plus(e)}function nn(n){return new this(n).asin()}function en(n){return new this(n).asinh()}function tn(n){return new this(n).atan()}function rn(n){return new this(n).atanh()}function sn(n,e){n=new this(n),e=new this(e);var t,i=this.precision,r=this.rounding,s=i+4;return n.s&&e.s?n.d||e.d?!e.d||n.isZero()?(t=e.s<0?_(this,i,r):new this(0)).s=n.s:!n.d||e.isZero()?(t=_(this,s,1).times(.5)).s=n.s:e.s<0?(this.precision=s,this.rounding=1,t=this.atan(F(n,e,s,1)),e=_(this,s,1),this.precision=i,this.rounding=r,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(F(n,e,s,1)):(t=_(this,s,1).times(e.s>0?.25:.75)).s=n.s:t=new this(NaN),t}function on(n){return new this(n).cbrt()}function un(n){return T(n=new this(n),n.e+1,2)}function cn(n,e,t){return new this(n).clamp(e,t)}function fn(n){if(!n||"object"!=typeof n)throw Error(h+"Object expected");var e,t,s,o=!0===n.defaults,u=["precision",1,r,"rounding",0,8,"toExpNeg",-9e15,0,"toExpPos",0,i,"maxE",0,i,"minE",-9e15,0,"modulo",0,9];for(e=0;e<u.length;e+=3)if(t=u[e],o&&(this[t]=c[t]),void 0!==(s=n[t])){if(!(p(s)===s&&s>=u[e+1]&&s<=u[e+2]))throw Error(a+t+": "+s);this[t]=s}if(t="crypto",o&&(this[t]=c[t]),void 0!==(s=n[t])){if(!0!==s&&!1!==s&&0!==s&&1!==s)throw Error(a+t+": "+s);if(s){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(d);this[t]=!0}else this[t]=!1}return this}function hn(n){return new this(n).cos()}function an(n){return new this(n).cosh()}function ln(n,e){return new this(n).div(e)}function dn(n){return new this(n).exp()}function gn(n){return T(n=new this(n),n.e+1,3)}function pn(){var n,e,t=new this(0);for(f=!1,n=0;n<arguments.length;)if((e=new this(arguments[n++])).d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return f=!0,new this(1/0);t=e}return f=!0,t.sqrt()}function mn(n){return n instanceof Pn||n&&n.toStringTag===g||!1}function wn(n){return new this(n).ln()}function vn(n,e){return new this(n).log(e)}function Nn(n){return new this(n).log(2)}function bn(n){return new this(n).log(10)}function En(){return C(this,arguments,-1)}function yn(){return C(this,arguments,1)}function xn(n,e){return new this(n).mod(e)}function Sn(n,e){return new this(n).mul(e)}function Mn(n,e){return new this(n).pow(e)}function Dn(n){var e,t,i,s,o=0,u=new this(1),c=[];if(void 0===n?n=this.precision:D(n,1,r),i=Math.ceil(n/7),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));o<i;)(s=e[o])>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:c[o++]=s%1e7;else{if(!crypto.randomBytes)throw Error(d);for(e=crypto.randomBytes(i*=4);o<i;)(s=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((127&e[o+3])<<24))>=214e7?crypto.randomBytes(4).copy(e,o):(c.push(s%1e7),o+=4);o=i/4}else for(;o<i;)c[o++]=1e7*Math.random()|0;for(n%=7,(i=c[--o])&&n&&(s=m(10,7-n),c[o]=(i/s|0)*s);0===c[o];o--)c.pop();if(o<0)t=0,c=[0];else{for(t=-1;0===c[0];t-=7)c.shift();for(i=1,s=c[0];s>=10;s/=10)i++;i<7&&(t-=7-i)}return u.e=t,u.d=c,u}function On(n){return T(n=new this(n),n.e+1,this.rounding)}function qn(n){return(n=new this(n)).d?n.d[0]?n.s:0*n.s:n.s||NaN}function Fn(n){return new this(n).sin()}function Tn(n){return new this(n).sinh()}function Rn(n){return new this(n).sqrt()}function Un(n,e){return new this(n).sub(e)}function An(){var n=0,e=arguments,t=new this(e[n]);for(f=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return f=!0,T(t,this.precision,this.rounding)}function _n(n){return new this(n).tan()}function Zn(n){return new this(n).tanh()}function In(n){return T(n=new this(n),n.e+1,1)}S[Symbol.for("nodejs.util.inspect.custom")]=S.toString,S[Symbol.toStringTag]="Decimal";var Pn=S.constructor=function n(e){var t,i,r;function s(n){var e,t,i,r=this;if(!(r instanceof s))return new s(n);if(r.constructor=s,mn(n))return r.s=n.s,void(f?!n.d||n.e>s.maxE?(r.e=NaN,r.d=null):n.e<s.minE?(r.e=0,r.d=[0]):(r.e=n.e,r.d=n.d.slice()):(r.e=n.e,r.d=n.d?n.d.slice():n.d));if("number"===(i=typeof n)){if(0===n)return r.s=1/n<0?-1:1,r.e=0,void(r.d=[0]);if(n<0?(n=-n,r.s=-1):r.s=1,n===~~n&&n<1e7){for(e=0,t=n;t>=10;t/=10)e++;return void(f?e>s.maxE?(r.e=NaN,r.d=null):e<s.minE?(r.e=0,r.d=[0]):(r.e=e,r.d=[n]):(r.e=e,r.d=[n]))}return 0*n!=0?(n||(r.s=NaN),r.e=NaN,void(r.d=null)):H(r,n.toString())}if("string"===i)return 45===(t=n.charCodeAt(0))?(n=n.slice(1),r.s=-1):(43===t&&(n=n.slice(1)),r.s=1),b.test(n)?H(r,n):j(r,n);if("bigint"===i)return n<0?(n=-n,r.s=-1):r.s=1,H(r,n.toString());throw Error(a+n)}if(s.prototype=S,s.ROUND_UP=0,s.ROUND_DOWN=1,s.ROUND_CEIL=2,s.ROUND_FLOOR=3,s.ROUND_HALF_UP=4,s.ROUND_HALF_DOWN=5,s.ROUND_HALF_EVEN=6,s.ROUND_HALF_CEIL=7,s.ROUND_HALF_FLOOR=8,s.EUCLID=9,s.config=s.set=fn,s.clone=n,s.isDecimal=mn,s.abs=K,s.acos=Q,s.acosh=X,s.add=Y,s.asin=nn,s.asinh=en,s.atan=tn,s.atanh=rn,s.atan2=sn,s.cbrt=on,s.ceil=un,s.clamp=cn,s.cos=hn,s.cosh=an,s.div=ln,s.exp=dn,s.floor=gn,s.hypot=pn,s.ln=wn,s.log=vn,s.log10=bn,s.log2=Nn,s.max=En,s.min=yn,s.mod=xn,s.mul=Sn,s.pow=Mn,s.random=Dn,s.round=On,s.sign=qn,s.sin=Fn,s.sinh=Tn,s.sqrt=Rn,s.sub=Un,s.sum=An,s.tan=_n,s.tanh=Zn,s.trunc=In,void 0===e&&(e={}),e&&!0!==e.defaults)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<r.length;)e.hasOwnProperty(i=r[t++])||(e[i]=this[i]);return s.config(e),s}(c);o=new Pn(o),u=new Pn(u);
9
9
  /*!
10
10
  * smart-unit
11
11
  * Copyright (c) [2026] [flycran]
12
12
  * MIT License. See LICENSE for details.
13
13
  */
14
- const kn="Accepting NaN as an argument may be unintentional and could lead to invalid results. If this is intentional, please set `SmartUnit.ignoreNaNInputs` to `true`.",Cn="By default, only number input is supported. To enable high-precision calculations, explicitly set the decimalSafety parameter to true.";class Ln{constructor(n,e={}){if(this.units=n,this.unitsStr=[],this.DecimalClass=In,!n.length)throw new Error("units is empty.");if(this.threshold=e.threshold||1,this.decimal=e.fractionDigits,this.highPrecision=e.useDecimal,e.decimalOptions&&(this.DecimalClass=In.clone(e.decimalOptions)),e.baseDigit){const i=[];for(let t=0;t<n.length;t++)this.unitsStr.push(n[t].toString()),i.push(n[t],e.baseDigit);this.units=i.slice(0,-1)}else{for(let e=0;e<n.length;e+=2)this.unitsStr.push(n[e].toString());this.units=n}}getUnit(n){if(!Ln.ignoreNaNInputs&&Number.isNaN(n))throw new Error(kn);let e=1;if(this.highPrecision){const i=new this.DecimalClass("bigint"==typeof n?n.toString():n),t=i.isNegative();let r=t?i.abs():i;for(;e<this.units.length-1;){const n=this.units[e];if("string"==typeof n)throw new Error(`The unit setting is incorrect; the element at index [${e}] should be of numeric type.`);if(r.lt(n*this.threshold))break;r=r.dividedBy(n),e+=2}const s=t?r.neg():r;return{num:s.toNumber(),decimal:s,unit:this.units[e-1].toString()}}{if("number"!=typeof n)throw new Error(Cn);const i=n<0;let t=i?-n:n;for(;e<this.units.length-1;){const n=this.units[e];if("string"==typeof n)throw new Error(`The unit setting is incorrect; the element at index [${e}] should be of numeric type.`);if(t<n*this.threshold)break;t/=n,e+=2}return{num:i?-t:t,unit:this.units[e-1].toString()}}}format(n,e=this.decimal){const{num:i,unit:t,decimal:r}=this.getUnit(n);let s;if("number"==typeof e)s=(null!=r?r:i).toFixed(e);else if("string"==typeof e){const[n,t]=e.split("-"),o=(i.toString().split(".")[1]||"").length,u=n?+n:-1/0,c=t?+t:1/0;s=o<u?(null!=r?r:i).toFixed(u):o>c?(null!=r?r:i).toFixed(c):(null!=r?r:i).toString()}else s=(null!=r?r:i).toString();return`${s}${t}`}toBase(n,e){if(!Ln.ignoreNaNInputs&&Number.isNaN(n))throw new Error(kn);let i=0;if(this.highPrecision){let t=new this.DecimalClass("bigint"==typeof n?n.toString():n);for(;i<this.units.length;){if(this.units[i]===e)return t;if(void 0===this.units[i])break;const n=this.units[i+1];if("number"!=typeof n)throw Error(`The unit setting is incorrect; the element at index [${i}] should be of numeric type.`);t=t.times(n),i+=2}}else{if("number"!=typeof n)throw new Error(Cn);let t=n;for(;i<this.units.length;){if(this.units[i]===e)return t;if(void 0===this.units[i+1])break;if("number"!=typeof this.units[i+1])throw Error(`The unit setting is incorrect; the element at index [${i}] should be of numeric type.`);t*=this.units[i+1],i+=2}}throw new Error(`Undefined unit: "${e}".`)}splitUnit(n){const e=new RegExp(`^(\\d+(?:\\.\\d+)?)(${this.unitsStr.map((n=>`${n}`)).join("|")})`),[,i,t]=n.match(e)||[];if(void 0===i||void 0===t)throw new Error(`Undefined unit: "${n}".`);return{num:+i,unit:t,decimal:this.highPrecision?new this.DecimalClass(i):void 0}}parse(n){const{num:e,unit:i,decimal:t}=this.splitUnit(n);return this.toBase(null!=t?t:e,i)}fromUnitFormat(n,e,i){const t=this.toBase(n,e);return this.format(t,i)}}Ln.ignoreNaNInputs=!1,n.ERROR_HIGH_PRECISION_NOT_ENABLED=Cn,n.ERROR_NAN_INPUT=kn,n.SmartUnit=Ln,n.default=Ln,Object.defineProperty(n,"__esModule",{value:!0})}));
14
+ const kn="Accepting NaN as an argument may be unintentional and could lead to invalid results. If this is intentional, please set `SmartUnit.ignoreNaNInputs` to `true`.",Cn="By default, only number input is supported. To enable high-precision calculations, explicitly set the decimalSafety parameter to true.";class Ln{constructor(n,e={}){if(this.units=n,this.unitsStr=[],this.DecimalClass=Pn,!n.length)throw new Error("units is empty.");if(this.threshold=e.threshold||1,this.fractionDigits=e.fractionDigits,this.useDecimal=e.useDecimal,e.decimalOptions&&(this.DecimalClass=Pn.clone(e.decimalOptions)),e.baseDigit){const t=[];for(let i=0;i<n.length;i++)this.unitsStr.push(n[i].toString()),t.push(n[i],e.baseDigit);this.units=t.slice(0,-1)}else{for(let e=0;e<n.length;e+=2)this.unitsStr.push(n[e].toString());this.units=n}}getUnit(n){if(!Ln.ignoreNaNInputs&&Number.isNaN(n))throw new Error(kn);let e=1;if(this.useDecimal){const t=new this.DecimalClass("bigint"==typeof n?n.toString():n),i=t.isNegative();let r=i?t.abs():t;for(;e<this.units.length-1;){const n=this.units[e];if("string"==typeof n)throw new Error(`The unit setting is incorrect; the element at index [${e}] should be of numeric type.`);if(r.lt(n*this.threshold))break;r=r.dividedBy(n),e+=2}const s=i?r.neg():r;return{num:s.toNumber(),decimal:s,unit:this.units[e-1].toString()}}{if("number"!=typeof n)throw new Error(Cn);const t=n<0;let i=t?-n:n;for(;e<this.units.length-1;){const n=this.units[e];if("string"==typeof n)throw new Error(`The unit setting is incorrect; the element at index [${e}] should be of numeric type.`);if(i<n*this.threshold)break;i/=n,e+=2}return{num:t?-i:i,unit:this.units[e-1].toString()}}}format(n,e=this.fractionDigits){const{num:t,unit:i,decimal:r}=this.getUnit(n);let s;if("number"==typeof e)s=(null!=r?r:t).toFixed(e);else if("string"==typeof e){const[n,i]=e.split("-"),o=(t.toString().split(".")[1]||"").length,u=n?+n:-1/0,c=i?+i:1/0;s=o<u?(null!=r?r:t).toFixed(u):o>c?(null!=r?r:t).toFixed(c):(null!=r?r:t).toString()}else s=(null!=r?r:t).toString();return`${s}${i}`}toBase(n,e){if(!Ln.ignoreNaNInputs&&Number.isNaN(n))throw new Error(kn);let t=0;if(this.useDecimal){let i=new this.DecimalClass("bigint"==typeof n?n.toString():n);for(;t<this.units.length;){if(this.units[t]===e)return i;if(void 0===this.units[t])break;const n=this.units[t+1];if("number"!=typeof n)throw Error(`The unit setting is incorrect; the element at index [${t}] should be of numeric type.`);i=i.times(n),t+=2}}else{if("number"!=typeof n)throw new Error(Cn);let i=n;for(;t<this.units.length;){if(this.units[t]===e)return i;if(void 0===this.units[t+1])break;if("number"!=typeof this.units[t+1])throw Error(`The unit setting is incorrect; the element at index [${t}] should be of numeric type.`);i*=this.units[t+1],t+=2}}throw new Error(`Undefined unit: "${e}".`)}splitUnit(n){const e=new RegExp(`^(\\d+(?:\\.\\d+)?)(${this.unitsStr.map((n=>`${n}`)).join("|")})`),[,t,i]=n.match(e)||[];if(void 0===t||void 0===i)throw new Error(`Undefined unit: "${n}".`);return{num:+t,unit:i,decimal:this.useDecimal?new this.DecimalClass(t):void 0}}parse(n){const{num:e,unit:t,decimal:i}=this.splitUnit(n);return this.toBase(null!=i?i:e,t)}fromUnitFormat(n,e,t){const i=this.toBase(n,e);return this.format(i,t)}}Ln.ignoreNaNInputs=!1,n.ERROR_HIGH_PRECISION_NOT_ENABLED=Cn,n.ERROR_NAN_INPUT=kn,n.SmartUnit=Ln,n.default=Ln,Object.defineProperty(n,"__esModule",{value:!0})}));
package/dist/index.d.ts CHANGED
@@ -48,9 +48,9 @@ export declare class SmartUnit<HP extends boolean = false> {
48
48
  readonly units: (string | number)[];
49
49
  static ignoreNaNInputs: boolean;
50
50
  readonly threshold: number;
51
- readonly decimal?: FractionDigits;
51
+ readonly fractionDigits?: FractionDigits;
52
52
  readonly unitsStr: string[];
53
- readonly highPrecision: HP;
53
+ readonly useDecimal: HP;
54
54
  private DecimalClass;
55
55
  constructor(units: (string | number)[], option?: SmartUnitOptions<HP>);
56
56
  /**
@@ -64,13 +64,13 @@ export declare class SmartUnit<HP extends boolean = false> {
64
64
  * Formats a number as a string with optional decimal place configuration
65
65
  *
66
66
  * @param num - The number to convert to string
67
- * @param decimal - Decimal precision configuration (defaults to instance setting)
67
+ * @param fractionDigits - Decimal precision configuration (defaults to instance setting)
68
68
  * - If a number, defines fixed decimal places
69
69
  * - If a string in "min-max" format, defines a range of decimal places
70
70
  * - If omitted, uses the instance's default decimal configuration
71
71
  * @returns The formatted string representation with unit
72
72
  */
73
- format(num: Num<HP>, decimal?: FractionDigits): string;
73
+ format(num: Num<HP>, fractionDigits?: FractionDigits): string;
74
74
  /**
75
75
  * Converts a value from the specified unit to the base unit
76
76
  *
@@ -102,9 +102,9 @@ export declare class SmartUnit<HP extends boolean = false> {
102
102
  *
103
103
  * @param num - The number to convert
104
104
  * @param unit - The original unit
105
- * @param decimal - Optional decimal places for formatting output
105
+ * @param fractionDigits - Optional decimal places for formatting output
106
106
  * @returns The converted number as a formatted string
107
107
  */
108
- fromUnitFormat(num: Num<HP>, unit: string, decimal?: FractionDigits): string;
108
+ fromUnitFormat(num: Num<HP>, unit: string, fractionDigits?: FractionDigits): string;
109
109
  }
110
110
  export default SmartUnit;
package/dist/index.esm.js CHANGED
@@ -15,8 +15,8 @@ class SmartUnit {
15
15
  if (!units.length)
16
16
  throw new Error('units is empty.');
17
17
  this.threshold = option.threshold || 1;
18
- this.decimal = option.fractionDigits;
19
- this.highPrecision = option.useDecimal;
18
+ this.fractionDigits = option.fractionDigits;
19
+ this.useDecimal = option.useDecimal;
20
20
  if (option.decimalOptions) {
21
21
  this.DecimalClass = DecimalConstructor.clone(option.decimalOptions);
22
22
  }
@@ -46,7 +46,7 @@ class SmartUnit {
46
46
  if (!SmartUnit.ignoreNaNInputs && Number.isNaN(num))
47
47
  throw new Error(ERROR_NAN_INPUT);
48
48
  let i = 1;
49
- if (this.highPrecision) {
49
+ if (this.useDecimal) {
50
50
  const dn = new this.DecimalClass(typeof num === 'bigint' ? num.toString() : num);
51
51
  const isNegative = dn.isNegative();
52
52
  let absDn = isNegative ? dn.abs() : dn;
@@ -93,20 +93,20 @@ class SmartUnit {
93
93
  * Formats a number as a string with optional decimal place configuration
94
94
  *
95
95
  * @param num - The number to convert to string
96
- * @param decimal - Decimal precision configuration (defaults to instance setting)
96
+ * @param fractionDigits - Decimal precision configuration (defaults to instance setting)
97
97
  * - If a number, defines fixed decimal places
98
98
  * - If a string in "min-max" format, defines a range of decimal places
99
99
  * - If omitted, uses the instance's default decimal configuration
100
100
  * @returns The formatted string representation with unit
101
101
  */
102
- format(num, decimal = this.decimal) {
102
+ format(num, fractionDigits = this.fractionDigits) {
103
103
  const { num: n, unit, decimal: dec, } = this.getUnit(num);
104
104
  let ns;
105
- if (typeof decimal === 'number') {
106
- ns = (dec !== null && dec !== undefined ? dec : n).toFixed(decimal);
105
+ if (typeof fractionDigits === 'number') {
106
+ ns = (dec !== null && dec !== undefined ? dec : n).toFixed(fractionDigits);
107
107
  }
108
- else if (typeof decimal === 'string') {
109
- const [dp1, dp2] = decimal
108
+ else if (typeof fractionDigits === 'string') {
109
+ const [dp1, dp2] = fractionDigits
110
110
  .split('-');
111
111
  const ndp = (n.toString().split('.')[1] || '').length;
112
112
  const minDp = dp1 ? +dp1 : -Infinity;
@@ -139,7 +139,7 @@ class SmartUnit {
139
139
  if (!SmartUnit.ignoreNaNInputs && Number.isNaN(num))
140
140
  throw new Error(ERROR_NAN_INPUT);
141
141
  let i = 0;
142
- if (this.highPrecision) {
142
+ if (this.useDecimal) {
143
143
  // High-precision calculation
144
144
  let dn = new this.DecimalClass(typeof num === 'bigint' ? num.toString() : num);
145
145
  while (i < this.units.length) {
@@ -194,7 +194,7 @@ class SmartUnit {
194
194
  return {
195
195
  num: +num,
196
196
  unit,
197
- decimal: this.highPrecision ? new this.DecimalClass(num) : undefined,
197
+ decimal: this.useDecimal ? new this.DecimalClass(num) : undefined,
198
198
  };
199
199
  }
200
200
  // 将带单位的值转换为基础单位的数值
@@ -215,12 +215,12 @@ class SmartUnit {
215
215
  *
216
216
  * @param num - The number to convert
217
217
  * @param unit - The original unit
218
- * @param decimal - Optional decimal places for formatting output
218
+ * @param fractionDigits - Optional decimal places for formatting output
219
219
  * @returns The converted number as a formatted string
220
220
  */
221
- fromUnitFormat(num, unit, decimal) {
221
+ fromUnitFormat(num, unit, fractionDigits) {
222
222
  const nnum = this.toBase(num, unit);
223
- return this.format(nnum, decimal);
223
+ return this.format(nnum, fractionDigits);
224
224
  }
225
225
  }
226
226
  SmartUnit.ignoreNaNInputs = false;
package/dist/index.js CHANGED
@@ -19,8 +19,8 @@ class SmartUnit {
19
19
  if (!units.length)
20
20
  throw new Error('units is empty.');
21
21
  this.threshold = option.threshold || 1;
22
- this.decimal = option.fractionDigits;
23
- this.highPrecision = option.useDecimal;
22
+ this.fractionDigits = option.fractionDigits;
23
+ this.useDecimal = option.useDecimal;
24
24
  if (option.decimalOptions) {
25
25
  this.DecimalClass = DecimalConstructor.clone(option.decimalOptions);
26
26
  }
@@ -50,7 +50,7 @@ class SmartUnit {
50
50
  if (!SmartUnit.ignoreNaNInputs && Number.isNaN(num))
51
51
  throw new Error(ERROR_NAN_INPUT);
52
52
  let i = 1;
53
- if (this.highPrecision) {
53
+ if (this.useDecimal) {
54
54
  const dn = new this.DecimalClass(typeof num === 'bigint' ? num.toString() : num);
55
55
  const isNegative = dn.isNegative();
56
56
  let absDn = isNegative ? dn.abs() : dn;
@@ -97,20 +97,20 @@ class SmartUnit {
97
97
  * Formats a number as a string with optional decimal place configuration
98
98
  *
99
99
  * @param num - The number to convert to string
100
- * @param decimal - Decimal precision configuration (defaults to instance setting)
100
+ * @param fractionDigits - Decimal precision configuration (defaults to instance setting)
101
101
  * - If a number, defines fixed decimal places
102
102
  * - If a string in "min-max" format, defines a range of decimal places
103
103
  * - If omitted, uses the instance's default decimal configuration
104
104
  * @returns The formatted string representation with unit
105
105
  */
106
- format(num, decimal = this.decimal) {
106
+ format(num, fractionDigits = this.fractionDigits) {
107
107
  const { num: n, unit, decimal: dec, } = this.getUnit(num);
108
108
  let ns;
109
- if (typeof decimal === 'number') {
110
- ns = (dec !== null && dec !== undefined ? dec : n).toFixed(decimal);
109
+ if (typeof fractionDigits === 'number') {
110
+ ns = (dec !== null && dec !== undefined ? dec : n).toFixed(fractionDigits);
111
111
  }
112
- else if (typeof decimal === 'string') {
113
- const [dp1, dp2] = decimal
112
+ else if (typeof fractionDigits === 'string') {
113
+ const [dp1, dp2] = fractionDigits
114
114
  .split('-');
115
115
  const ndp = (n.toString().split('.')[1] || '').length;
116
116
  const minDp = dp1 ? +dp1 : -Infinity;
@@ -143,7 +143,7 @@ class SmartUnit {
143
143
  if (!SmartUnit.ignoreNaNInputs && Number.isNaN(num))
144
144
  throw new Error(ERROR_NAN_INPUT);
145
145
  let i = 0;
146
- if (this.highPrecision) {
146
+ if (this.useDecimal) {
147
147
  // High-precision calculation
148
148
  let dn = new this.DecimalClass(typeof num === 'bigint' ? num.toString() : num);
149
149
  while (i < this.units.length) {
@@ -198,7 +198,7 @@ class SmartUnit {
198
198
  return {
199
199
  num: +num,
200
200
  unit,
201
- decimal: this.highPrecision ? new this.DecimalClass(num) : undefined,
201
+ decimal: this.useDecimal ? new this.DecimalClass(num) : undefined,
202
202
  };
203
203
  }
204
204
  // 将带单位的值转换为基础单位的数值
@@ -219,12 +219,12 @@ class SmartUnit {
219
219
  *
220
220
  * @param num - The number to convert
221
221
  * @param unit - The original unit
222
- * @param decimal - Optional decimal places for formatting output
222
+ * @param fractionDigits - Optional decimal places for formatting output
223
223
  * @returns The converted number as a formatted string
224
224
  */
225
- fromUnitFormat(num, unit, decimal) {
225
+ fromUnitFormat(num, unit, fractionDigits) {
226
226
  const nnum = this.toBase(num, unit);
227
- return this.format(nnum, decimal);
227
+ return this.format(nnum, fractionDigits);
228
228
  }
229
229
  }
230
230
  SmartUnit.ignoreNaNInputs = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-unit",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Elegant unit conversion utility with automatic unit selection and high-precision support",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -59,4 +59,4 @@
59
59
  "dependencies": {
60
60
  "decimal.js": "^10.5.0"
61
61
  }
62
- }
62
+ }