@formatjs/intl-segmenter 12.1.2 → 12.2.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/package.json +2 -2
- package/polyfill.iife.js +598 -2348
package/polyfill.iife.js
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
6
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7
|
-
var __spreadValues = (a, b) => {
|
|
8
|
-
for (var prop in b || (b = {}))
|
|
9
|
-
if (__hasOwnProp.call(b, prop))
|
|
10
|
-
__defNormalProp(a, prop, b[prop]);
|
|
11
|
-
if (__getOwnPropSymbols)
|
|
12
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
13
|
-
if (__propIsEnum.call(b, prop))
|
|
14
|
-
__defNormalProp(a, prop, b[prop]);
|
|
15
|
-
}
|
|
16
|
-
return a;
|
|
17
|
-
};
|
|
18
4
|
var __publicField = (obj, key, value) => {
|
|
19
5
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
20
6
|
return value;
|
|
@@ -25,2371 +11,646 @@
|
|
|
25
11
|
return Intl.getCanonicalLocales(locales);
|
|
26
12
|
}
|
|
27
13
|
|
|
28
|
-
// node_modules/.aspect_rules_js
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
toExpPos: 21,
|
|
80
|
-
// 0 to EXP_LIMIT
|
|
81
|
-
// The minimum exponent value, beneath which underflow to zero occurs.
|
|
82
|
-
// JavaScript numbers: -324 (5e-324)
|
|
83
|
-
minE: -EXP_LIMIT,
|
|
84
|
-
// -1 to -EXP_LIMIT
|
|
85
|
-
// The maximum exponent value, above which overflow to Infinity occurs.
|
|
86
|
-
// JavaScript numbers: 308 (1.7976931348623157e+308)
|
|
87
|
-
maxE: EXP_LIMIT,
|
|
88
|
-
// 1 to EXP_LIMIT
|
|
89
|
-
// Whether to use cryptographically-secure random number generation, if available.
|
|
90
|
-
crypto: false
|
|
91
|
-
// true/false
|
|
92
|
-
};
|
|
93
|
-
var inexact;
|
|
94
|
-
var quadrant;
|
|
95
|
-
var external = true;
|
|
96
|
-
var decimalError = "[DecimalError] ";
|
|
97
|
-
var invalidArgument = decimalError + "Invalid argument: ";
|
|
98
|
-
var precisionLimitExceeded = decimalError + "Precision limit exceeded";
|
|
99
|
-
var cryptoUnavailable = decimalError + "crypto unavailable";
|
|
100
|
-
var tag = "[object Decimal]";
|
|
101
|
-
var mathfloor = Math.floor;
|
|
102
|
-
var mathpow = Math.pow;
|
|
103
|
-
var isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i;
|
|
104
|
-
var isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i;
|
|
105
|
-
var isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i;
|
|
106
|
-
var isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
|
|
107
|
-
var BASE = 1e7;
|
|
108
|
-
var LOG_BASE = 7;
|
|
109
|
-
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
110
|
-
var LN10_PRECISION = LN10.length - 1;
|
|
111
|
-
var PI_PRECISION = PI.length - 1;
|
|
112
|
-
var P = { toStringTag: tag };
|
|
113
|
-
P.absoluteValue = P.abs = function() {
|
|
114
|
-
var x = new this.constructor(this);
|
|
115
|
-
if (x.s < 0)
|
|
116
|
-
x.s = 1;
|
|
117
|
-
return finalise(x);
|
|
118
|
-
};
|
|
119
|
-
P.ceil = function() {
|
|
120
|
-
return finalise(new this.constructor(this), this.e + 1, 2);
|
|
121
|
-
};
|
|
122
|
-
P.clampedTo = P.clamp = function(min2, max2) {
|
|
123
|
-
var k, x = this, Ctor = x.constructor;
|
|
124
|
-
min2 = new Ctor(min2);
|
|
125
|
-
max2 = new Ctor(max2);
|
|
126
|
-
if (!min2.s || !max2.s)
|
|
127
|
-
return new Ctor(NaN);
|
|
128
|
-
if (min2.gt(max2))
|
|
129
|
-
throw Error(invalidArgument + max2);
|
|
130
|
-
k = x.cmp(min2);
|
|
131
|
-
return k < 0 ? min2 : x.cmp(max2) > 0 ? max2 : new Ctor(x);
|
|
132
|
-
};
|
|
133
|
-
P.comparedTo = P.cmp = function(y) {
|
|
134
|
-
var i, j, xdL, ydL, x = this, xd = x.d, yd = (y = new x.constructor(y)).d, xs = x.s, ys = y.s;
|
|
135
|
-
if (!xd || !yd) {
|
|
136
|
-
return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
|
|
137
|
-
}
|
|
138
|
-
if (!xd[0] || !yd[0])
|
|
139
|
-
return xd[0] ? xs : yd[0] ? -ys : 0;
|
|
140
|
-
if (xs !== ys)
|
|
141
|
-
return xs;
|
|
142
|
-
if (x.e !== y.e)
|
|
143
|
-
return x.e > y.e ^ xs < 0 ? 1 : -1;
|
|
144
|
-
xdL = xd.length;
|
|
145
|
-
ydL = yd.length;
|
|
146
|
-
for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
|
|
147
|
-
if (xd[i] !== yd[i])
|
|
148
|
-
return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
|
|
14
|
+
// node_modules/.aspect_rules_js/@formatjs+bigdecimal@0.0.0/node_modules/@formatjs/bigdecimal/index.js
|
|
15
|
+
var DIV_PRECISION = 40;
|
|
16
|
+
var SpecialValue = function(SpecialValue2) {
|
|
17
|
+
SpecialValue2[SpecialValue2["NONE"] = 0] = "NONE";
|
|
18
|
+
SpecialValue2[SpecialValue2["NAN"] = 1] = "NAN";
|
|
19
|
+
SpecialValue2[SpecialValue2["POSITIVE_INFINITY"] = 2] = "POSITIVE_INFINITY";
|
|
20
|
+
SpecialValue2[SpecialValue2["NEGATIVE_INFINITY"] = 3] = "NEGATIVE_INFINITY";
|
|
21
|
+
return SpecialValue2;
|
|
22
|
+
}(SpecialValue || {});
|
|
23
|
+
function removeTrailingZeros(mantissa, exponent) {
|
|
24
|
+
if (mantissa === 0n)
|
|
25
|
+
return [0n, 0];
|
|
26
|
+
while (mantissa % 10n === 0n) {
|
|
27
|
+
mantissa /= 10n;
|
|
28
|
+
exponent++;
|
|
29
|
+
}
|
|
30
|
+
return [mantissa, exponent];
|
|
31
|
+
}
|
|
32
|
+
function bigintAbs(n) {
|
|
33
|
+
return n < 0n ? -n : n;
|
|
34
|
+
}
|
|
35
|
+
function digitCount(n) {
|
|
36
|
+
if (n === 0n)
|
|
37
|
+
return 1;
|
|
38
|
+
if (n < 0n)
|
|
39
|
+
n = -n;
|
|
40
|
+
let count = 0;
|
|
41
|
+
const big15 = 1000000000000000n;
|
|
42
|
+
while (n >= big15) {
|
|
43
|
+
n /= big15;
|
|
44
|
+
count += 15;
|
|
45
|
+
}
|
|
46
|
+
let r = Number(n);
|
|
47
|
+
while (r >= 1) {
|
|
48
|
+
r /= 10;
|
|
49
|
+
count++;
|
|
50
|
+
}
|
|
51
|
+
return count;
|
|
52
|
+
}
|
|
53
|
+
var TEN_BIGINT = 10n;
|
|
54
|
+
function bigintPow10(n) {
|
|
55
|
+
if (n <= 0)
|
|
56
|
+
return 1n;
|
|
57
|
+
let result = 1n;
|
|
58
|
+
let base = TEN_BIGINT;
|
|
59
|
+
let exp = n;
|
|
60
|
+
while (exp > 0) {
|
|
61
|
+
if (exp & 1)
|
|
62
|
+
result *= base;
|
|
63
|
+
base *= base;
|
|
64
|
+
exp >>= 1;
|
|
149
65
|
}
|
|
150
|
-
return
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
return
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
Ctor.rounding = 1;
|
|
162
|
-
x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
163
|
-
Ctor.precision = pr;
|
|
164
|
-
Ctor.rounding = rm;
|
|
165
|
-
return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
|
|
166
|
-
};
|
|
167
|
-
P.cubeRoot = P.cbrt = function() {
|
|
168
|
-
var e, m, n, r, rep, s, sd, t, t3, t3plusx, x = this, Ctor = x.constructor;
|
|
169
|
-
if (!x.isFinite() || x.isZero())
|
|
170
|
-
return new Ctor(x);
|
|
171
|
-
external = false;
|
|
172
|
-
s = x.s * mathpow(x.s * x, 1 / 3);
|
|
173
|
-
if (!s || Math.abs(s) == 1 / 0) {
|
|
174
|
-
n = digitsToString(x.d);
|
|
175
|
-
e = x.e;
|
|
176
|
-
if (s = (e - n.length + 1) % 3)
|
|
177
|
-
n += s == 1 || s == -2 ? "0" : "00";
|
|
178
|
-
s = mathpow(n, 1 / 3);
|
|
179
|
-
e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
|
|
180
|
-
if (s == 1 / 0) {
|
|
181
|
-
n = "5e" + e;
|
|
182
|
-
} else {
|
|
183
|
-
n = s.toExponential();
|
|
184
|
-
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
185
|
-
}
|
|
186
|
-
r = new Ctor(n);
|
|
187
|
-
r.s = x.s;
|
|
188
|
-
} else {
|
|
189
|
-
r = new Ctor(s.toString());
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
function parseDecimalString(s) {
|
|
69
|
+
s = s.trim();
|
|
70
|
+
if (s === "NaN") {
|
|
71
|
+
return {
|
|
72
|
+
mantissa: 0n,
|
|
73
|
+
exponent: 0,
|
|
74
|
+
special: SpecialValue.NAN,
|
|
75
|
+
negativeZero: false
|
|
76
|
+
};
|
|
190
77
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
n = n.slice(sd - 3, sd + 1);
|
|
199
|
-
if (n == "9999" || !rep && n == "4999") {
|
|
200
|
-
if (!rep) {
|
|
201
|
-
finalise(t, e + 1, 0);
|
|
202
|
-
if (t.times(t).times(t).eq(x)) {
|
|
203
|
-
r = t;
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
sd += 4;
|
|
208
|
-
rep = 1;
|
|
209
|
-
} else {
|
|
210
|
-
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
211
|
-
finalise(r, e + 1, 1);
|
|
212
|
-
m = !r.times(r).times(r).eq(x);
|
|
213
|
-
}
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
78
|
+
if (s === "Infinity" || s === "+Infinity") {
|
|
79
|
+
return {
|
|
80
|
+
mantissa: 0n,
|
|
81
|
+
exponent: 0,
|
|
82
|
+
special: SpecialValue.POSITIVE_INFINITY,
|
|
83
|
+
negativeZero: false
|
|
84
|
+
};
|
|
217
85
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
|
|
226
|
-
w = d[w];
|
|
227
|
-
if (w)
|
|
228
|
-
for (; w % 10 == 0; w /= 10)
|
|
229
|
-
n--;
|
|
230
|
-
if (n < 0)
|
|
231
|
-
n = 0;
|
|
86
|
+
if (s === "-Infinity") {
|
|
87
|
+
return {
|
|
88
|
+
mantissa: 0n,
|
|
89
|
+
exponent: 0,
|
|
90
|
+
special: SpecialValue.NEGATIVE_INFINITY,
|
|
91
|
+
negativeZero: false
|
|
92
|
+
};
|
|
232
93
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return this.cmp(y) > 0;
|
|
250
|
-
};
|
|
251
|
-
P.greaterThanOrEqualTo = P.gte = function(y) {
|
|
252
|
-
var k = this.cmp(y);
|
|
253
|
-
return k == 1 || k === 0;
|
|
254
|
-
};
|
|
255
|
-
P.hyperbolicCosine = P.cosh = function() {
|
|
256
|
-
var k, n, pr, rm, len, x = this, Ctor = x.constructor, one = new Ctor(1);
|
|
257
|
-
if (!x.isFinite())
|
|
258
|
-
return new Ctor(x.s ? 1 / 0 : NaN);
|
|
259
|
-
if (x.isZero())
|
|
260
|
-
return one;
|
|
261
|
-
pr = Ctor.precision;
|
|
262
|
-
rm = Ctor.rounding;
|
|
263
|
-
Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
|
|
264
|
-
Ctor.rounding = 1;
|
|
265
|
-
len = x.d.length;
|
|
266
|
-
if (len < 32) {
|
|
267
|
-
k = Math.ceil(len / 3);
|
|
268
|
-
n = (1 / tinyPow(4, k)).toString();
|
|
94
|
+
let negative = false;
|
|
95
|
+
let idx = 0;
|
|
96
|
+
if (s[idx] === "-") {
|
|
97
|
+
negative = true;
|
|
98
|
+
idx++;
|
|
99
|
+
} else if (s[idx] === "+") {
|
|
100
|
+
idx++;
|
|
101
|
+
}
|
|
102
|
+
let eIdx = s.indexOf("e", idx);
|
|
103
|
+
if (eIdx === -1)
|
|
104
|
+
eIdx = s.indexOf("E", idx);
|
|
105
|
+
let sciExp = 0;
|
|
106
|
+
let numPart;
|
|
107
|
+
if (eIdx !== -1) {
|
|
108
|
+
sciExp = parseInt(s.substring(eIdx + 1), 10);
|
|
109
|
+
numPart = s.substring(idx, eIdx);
|
|
269
110
|
} else {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
|
|
280
|
-
};
|
|
281
|
-
P.hyperbolicSine = P.sinh = function() {
|
|
282
|
-
var k, pr, rm, len, x = this, Ctor = x.constructor;
|
|
283
|
-
if (!x.isFinite() || x.isZero())
|
|
284
|
-
return new Ctor(x);
|
|
285
|
-
pr = Ctor.precision;
|
|
286
|
-
rm = Ctor.rounding;
|
|
287
|
-
Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
|
|
288
|
-
Ctor.rounding = 1;
|
|
289
|
-
len = x.d.length;
|
|
290
|
-
if (len < 3) {
|
|
291
|
-
x = taylorSeries(Ctor, 2, x, x, true);
|
|
111
|
+
numPart = s.substring(idx);
|
|
112
|
+
}
|
|
113
|
+
const dotIdx = numPart.indexOf(".");
|
|
114
|
+
let intPart;
|
|
115
|
+
let fracPart;
|
|
116
|
+
if (dotIdx !== -1) {
|
|
117
|
+
intPart = numPart.substring(0, dotIdx);
|
|
118
|
+
fracPart = numPart.substring(dotIdx + 1);
|
|
292
119
|
} else {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
return finalise(x, pr, rm, true);
|
|
306
|
-
};
|
|
307
|
-
P.hyperbolicTangent = P.tanh = function() {
|
|
308
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
309
|
-
if (!x.isFinite())
|
|
310
|
-
return new Ctor(x.s);
|
|
311
|
-
if (x.isZero())
|
|
312
|
-
return new Ctor(x);
|
|
313
|
-
pr = Ctor.precision;
|
|
314
|
-
rm = Ctor.rounding;
|
|
315
|
-
Ctor.precision = pr + 7;
|
|
316
|
-
Ctor.rounding = 1;
|
|
317
|
-
return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
|
|
318
|
-
};
|
|
319
|
-
P.inverseCosine = P.acos = function() {
|
|
320
|
-
var x = this, Ctor = x.constructor, k = x.abs().cmp(1), pr = Ctor.precision, rm = Ctor.rounding;
|
|
321
|
-
if (k !== -1) {
|
|
322
|
-
return k === 0 ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0) : new Ctor(NaN);
|
|
323
|
-
}
|
|
324
|
-
if (x.isZero())
|
|
325
|
-
return getPi(Ctor, pr + 4, rm).times(0.5);
|
|
326
|
-
Ctor.precision = pr + 6;
|
|
327
|
-
Ctor.rounding = 1;
|
|
328
|
-
x = new Ctor(1).minus(x).div(x.plus(1)).sqrt().atan();
|
|
329
|
-
Ctor.precision = pr;
|
|
330
|
-
Ctor.rounding = rm;
|
|
331
|
-
return x.times(2);
|
|
332
|
-
};
|
|
333
|
-
P.inverseHyperbolicCosine = P.acosh = function() {
|
|
334
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
335
|
-
if (x.lte(1))
|
|
336
|
-
return new Ctor(x.eq(1) ? 0 : NaN);
|
|
337
|
-
if (!x.isFinite())
|
|
338
|
-
return new Ctor(x);
|
|
339
|
-
pr = Ctor.precision;
|
|
340
|
-
rm = Ctor.rounding;
|
|
341
|
-
Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
|
|
342
|
-
Ctor.rounding = 1;
|
|
343
|
-
external = false;
|
|
344
|
-
x = x.times(x).minus(1).sqrt().plus(x);
|
|
345
|
-
external = true;
|
|
346
|
-
Ctor.precision = pr;
|
|
347
|
-
Ctor.rounding = rm;
|
|
348
|
-
return x.ln();
|
|
349
|
-
};
|
|
350
|
-
P.inverseHyperbolicSine = P.asinh = function() {
|
|
351
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
352
|
-
if (!x.isFinite() || x.isZero())
|
|
353
|
-
return new Ctor(x);
|
|
354
|
-
pr = Ctor.precision;
|
|
355
|
-
rm = Ctor.rounding;
|
|
356
|
-
Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
|
|
357
|
-
Ctor.rounding = 1;
|
|
358
|
-
external = false;
|
|
359
|
-
x = x.times(x).plus(1).sqrt().plus(x);
|
|
360
|
-
external = true;
|
|
361
|
-
Ctor.precision = pr;
|
|
362
|
-
Ctor.rounding = rm;
|
|
363
|
-
return x.ln();
|
|
364
|
-
};
|
|
365
|
-
P.inverseHyperbolicTangent = P.atanh = function() {
|
|
366
|
-
var pr, rm, wpr, xsd, x = this, Ctor = x.constructor;
|
|
367
|
-
if (!x.isFinite())
|
|
368
|
-
return new Ctor(NaN);
|
|
369
|
-
if (x.e >= 0)
|
|
370
|
-
return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
|
|
371
|
-
pr = Ctor.precision;
|
|
372
|
-
rm = Ctor.rounding;
|
|
373
|
-
xsd = x.sd();
|
|
374
|
-
if (Math.max(xsd, pr) < 2 * -x.e - 1)
|
|
375
|
-
return finalise(new Ctor(x), pr, rm, true);
|
|
376
|
-
Ctor.precision = wpr = xsd - x.e;
|
|
377
|
-
x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
|
|
378
|
-
Ctor.precision = pr + 4;
|
|
379
|
-
Ctor.rounding = 1;
|
|
380
|
-
x = x.ln();
|
|
381
|
-
Ctor.precision = pr;
|
|
382
|
-
Ctor.rounding = rm;
|
|
383
|
-
return x.times(0.5);
|
|
384
|
-
};
|
|
385
|
-
P.inverseSine = P.asin = function() {
|
|
386
|
-
var halfPi, k, pr, rm, x = this, Ctor = x.constructor;
|
|
387
|
-
if (x.isZero())
|
|
388
|
-
return new Ctor(x);
|
|
389
|
-
k = x.abs().cmp(1);
|
|
390
|
-
pr = Ctor.precision;
|
|
391
|
-
rm = Ctor.rounding;
|
|
392
|
-
if (k !== -1) {
|
|
393
|
-
if (k === 0) {
|
|
394
|
-
halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
395
|
-
halfPi.s = x.s;
|
|
396
|
-
return halfPi;
|
|
397
|
-
}
|
|
398
|
-
return new Ctor(NaN);
|
|
399
|
-
}
|
|
400
|
-
Ctor.precision = pr + 6;
|
|
401
|
-
Ctor.rounding = 1;
|
|
402
|
-
x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
|
|
403
|
-
Ctor.precision = pr;
|
|
404
|
-
Ctor.rounding = rm;
|
|
405
|
-
return x.times(2);
|
|
406
|
-
};
|
|
407
|
-
P.inverseTangent = P.atan = function() {
|
|
408
|
-
var i, j, k, n, px, t, r, wpr, x2, x = this, Ctor = x.constructor, pr = Ctor.precision, rm = Ctor.rounding;
|
|
409
|
-
if (!x.isFinite()) {
|
|
410
|
-
if (!x.s)
|
|
411
|
-
return new Ctor(NaN);
|
|
412
|
-
if (pr + 4 <= PI_PRECISION) {
|
|
413
|
-
r = getPi(Ctor, pr + 4, rm).times(0.5);
|
|
414
|
-
r.s = x.s;
|
|
415
|
-
return r;
|
|
416
|
-
}
|
|
417
|
-
} else if (x.isZero()) {
|
|
418
|
-
return new Ctor(x);
|
|
419
|
-
} else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
|
|
420
|
-
r = getPi(Ctor, pr + 4, rm).times(0.25);
|
|
421
|
-
r.s = x.s;
|
|
422
|
-
return r;
|
|
423
|
-
}
|
|
424
|
-
Ctor.precision = wpr = pr + 10;
|
|
425
|
-
Ctor.rounding = 1;
|
|
426
|
-
k = Math.min(28, wpr / LOG_BASE + 2 | 0);
|
|
427
|
-
for (i = k; i; --i)
|
|
428
|
-
x = x.div(x.times(x).plus(1).sqrt().plus(1));
|
|
429
|
-
external = false;
|
|
430
|
-
j = Math.ceil(wpr / LOG_BASE);
|
|
431
|
-
n = 1;
|
|
432
|
-
x2 = x.times(x);
|
|
433
|
-
r = new Ctor(x);
|
|
434
|
-
px = x;
|
|
435
|
-
for (; i !== -1; ) {
|
|
436
|
-
px = px.times(x2);
|
|
437
|
-
t = r.minus(px.div(n += 2));
|
|
438
|
-
px = px.times(x2);
|
|
439
|
-
r = t.plus(px.div(n += 2));
|
|
440
|
-
if (r.d[j] !== void 0)
|
|
441
|
-
for (i = j; r.d[i] === t.d[i] && i--; )
|
|
442
|
-
;
|
|
443
|
-
}
|
|
444
|
-
if (k)
|
|
445
|
-
r = r.times(2 << k - 1);
|
|
446
|
-
external = true;
|
|
447
|
-
return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
|
|
448
|
-
};
|
|
449
|
-
P.isFinite = function() {
|
|
450
|
-
return !!this.d;
|
|
451
|
-
};
|
|
452
|
-
P.isInteger = P.isInt = function() {
|
|
453
|
-
return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
|
|
454
|
-
};
|
|
455
|
-
P.isNaN = function() {
|
|
456
|
-
return !this.s;
|
|
457
|
-
};
|
|
458
|
-
P.isNegative = P.isNeg = function() {
|
|
459
|
-
return this.s < 0;
|
|
460
|
-
};
|
|
461
|
-
P.isPositive = P.isPos = function() {
|
|
462
|
-
return this.s > 0;
|
|
463
|
-
};
|
|
464
|
-
P.isZero = function() {
|
|
465
|
-
return !!this.d && this.d[0] === 0;
|
|
466
|
-
};
|
|
467
|
-
P.lessThan = P.lt = function(y) {
|
|
468
|
-
return this.cmp(y) < 0;
|
|
469
|
-
};
|
|
470
|
-
P.lessThanOrEqualTo = P.lte = function(y) {
|
|
471
|
-
return this.cmp(y) < 1;
|
|
472
|
-
};
|
|
473
|
-
P.logarithm = P.log = function(base) {
|
|
474
|
-
var isBase10, d, denominator, k, inf, num, sd, r, arg = this, Ctor = arg.constructor, pr = Ctor.precision, rm = Ctor.rounding, guard = 5;
|
|
475
|
-
if (base == null) {
|
|
476
|
-
base = new Ctor(10);
|
|
477
|
-
isBase10 = true;
|
|
478
|
-
} else {
|
|
479
|
-
base = new Ctor(base);
|
|
480
|
-
d = base.d;
|
|
481
|
-
if (base.s < 0 || !d || !d[0] || base.eq(1))
|
|
482
|
-
return new Ctor(NaN);
|
|
483
|
-
isBase10 = base.eq(10);
|
|
484
|
-
}
|
|
485
|
-
d = arg.d;
|
|
486
|
-
if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
|
|
487
|
-
return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
|
|
120
|
+
intPart = numPart;
|
|
121
|
+
fracPart = "";
|
|
122
|
+
}
|
|
123
|
+
const combined = intPart + fracPart;
|
|
124
|
+
const exponent = sciExp - fracPart.length;
|
|
125
|
+
if (combined === "" || combined === "0" || /^0+$/.test(combined)) {
|
|
126
|
+
return {
|
|
127
|
+
mantissa: 0n,
|
|
128
|
+
exponent: 0,
|
|
129
|
+
special: SpecialValue.NONE,
|
|
130
|
+
negativeZero: negative
|
|
131
|
+
};
|
|
488
132
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
133
|
+
let mantissa = BigInt(combined);
|
|
134
|
+
if (negative)
|
|
135
|
+
mantissa = -mantissa;
|
|
136
|
+
const [normMantissa, normExponent] = removeTrailingZeros(mantissa, exponent);
|
|
137
|
+
return {
|
|
138
|
+
mantissa: normMantissa,
|
|
139
|
+
exponent: normExponent,
|
|
140
|
+
special: SpecialValue.NONE,
|
|
141
|
+
negativeZero: false
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
var BigDecimal = class _BigDecimal {
|
|
145
|
+
constructor(value) {
|
|
146
|
+
__publicField(this, "_mantissa");
|
|
147
|
+
__publicField(this, "_exponent");
|
|
148
|
+
__publicField(this, "_special");
|
|
149
|
+
__publicField(this, "_negativeZero");
|
|
150
|
+
if (typeof value === "bigint") {
|
|
151
|
+
const [m, e] = removeTrailingZeros(value, 0);
|
|
152
|
+
this._mantissa = m;
|
|
153
|
+
this._exponent = e;
|
|
154
|
+
this._special = SpecialValue.NONE;
|
|
155
|
+
this._negativeZero = false;
|
|
156
|
+
return;
|
|
496
157
|
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
do {
|
|
505
|
-
sd += 10;
|
|
506
|
-
num = naturalLogarithm(arg, sd);
|
|
507
|
-
denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
|
|
508
|
-
r = divide(num, denominator, sd, 1);
|
|
509
|
-
if (!inf) {
|
|
510
|
-
if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) {
|
|
511
|
-
r = finalise(r, pr + 1, 0);
|
|
512
|
-
}
|
|
513
|
-
break;
|
|
158
|
+
if (typeof value === "number") {
|
|
159
|
+
if (Number.isNaN(value)) {
|
|
160
|
+
this._mantissa = 0n;
|
|
161
|
+
this._exponent = 0;
|
|
162
|
+
this._special = SpecialValue.NAN;
|
|
163
|
+
this._negativeZero = false;
|
|
164
|
+
return;
|
|
514
165
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd, x = this, Ctor = x.constructor;
|
|
522
|
-
y = new Ctor(y);
|
|
523
|
-
if (!x.d || !y.d) {
|
|
524
|
-
if (!x.s || !y.s)
|
|
525
|
-
y = new Ctor(NaN);
|
|
526
|
-
else if (x.d)
|
|
527
|
-
y.s = -y.s;
|
|
528
|
-
else
|
|
529
|
-
y = new Ctor(y.d || x.s !== y.s ? x : NaN);
|
|
530
|
-
return y;
|
|
531
|
-
}
|
|
532
|
-
if (x.s != y.s) {
|
|
533
|
-
y.s = -y.s;
|
|
534
|
-
return x.plus(y);
|
|
535
|
-
}
|
|
536
|
-
xd = x.d;
|
|
537
|
-
yd = y.d;
|
|
538
|
-
pr = Ctor.precision;
|
|
539
|
-
rm = Ctor.rounding;
|
|
540
|
-
if (!xd[0] || !yd[0]) {
|
|
541
|
-
if (yd[0])
|
|
542
|
-
y.s = -y.s;
|
|
543
|
-
else if (xd[0])
|
|
544
|
-
y = new Ctor(x);
|
|
545
|
-
else
|
|
546
|
-
return new Ctor(rm === 3 ? -0 : 0);
|
|
547
|
-
return external ? finalise(y, pr, rm) : y;
|
|
548
|
-
}
|
|
549
|
-
e = mathfloor(y.e / LOG_BASE);
|
|
550
|
-
xe = mathfloor(x.e / LOG_BASE);
|
|
551
|
-
xd = xd.slice();
|
|
552
|
-
k = xe - e;
|
|
553
|
-
if (k) {
|
|
554
|
-
xLTy = k < 0;
|
|
555
|
-
if (xLTy) {
|
|
556
|
-
d = xd;
|
|
557
|
-
k = -k;
|
|
558
|
-
len = yd.length;
|
|
559
|
-
} else {
|
|
560
|
-
d = yd;
|
|
561
|
-
e = xe;
|
|
562
|
-
len = xd.length;
|
|
563
|
-
}
|
|
564
|
-
i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
|
|
565
|
-
if (k > i) {
|
|
566
|
-
k = i;
|
|
567
|
-
d.length = 1;
|
|
568
|
-
}
|
|
569
|
-
d.reverse();
|
|
570
|
-
for (i = k; i--; )
|
|
571
|
-
d.push(0);
|
|
572
|
-
d.reverse();
|
|
573
|
-
} else {
|
|
574
|
-
i = xd.length;
|
|
575
|
-
len = yd.length;
|
|
576
|
-
xLTy = i < len;
|
|
577
|
-
if (xLTy)
|
|
578
|
-
len = i;
|
|
579
|
-
for (i = 0; i < len; i++) {
|
|
580
|
-
if (xd[i] != yd[i]) {
|
|
581
|
-
xLTy = xd[i] < yd[i];
|
|
582
|
-
break;
|
|
166
|
+
if (value === Infinity) {
|
|
167
|
+
this._mantissa = 0n;
|
|
168
|
+
this._exponent = 0;
|
|
169
|
+
this._special = SpecialValue.POSITIVE_INFINITY;
|
|
170
|
+
this._negativeZero = false;
|
|
171
|
+
return;
|
|
583
172
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
if (xd[--i] < yd[i]) {
|
|
598
|
-
for (j = i; j && xd[--j] === 0; )
|
|
599
|
-
xd[j] = BASE - 1;
|
|
600
|
-
--xd[j];
|
|
601
|
-
xd[i] += BASE;
|
|
602
|
-
}
|
|
603
|
-
xd[i] -= yd[i];
|
|
604
|
-
}
|
|
605
|
-
for (; xd[--len] === 0; )
|
|
606
|
-
xd.pop();
|
|
607
|
-
for (; xd[0] === 0; xd.shift())
|
|
608
|
-
--e;
|
|
609
|
-
if (!xd[0])
|
|
610
|
-
return new Ctor(rm === 3 ? -0 : 0);
|
|
611
|
-
y.d = xd;
|
|
612
|
-
y.e = getBase10Exponent(xd, e);
|
|
613
|
-
return external ? finalise(y, pr, rm) : y;
|
|
614
|
-
};
|
|
615
|
-
P.modulo = P.mod = function(y) {
|
|
616
|
-
var q, x = this, Ctor = x.constructor;
|
|
617
|
-
y = new Ctor(y);
|
|
618
|
-
if (!x.d || !y.s || y.d && !y.d[0])
|
|
619
|
-
return new Ctor(NaN);
|
|
620
|
-
if (!y.d || x.d && !x.d[0]) {
|
|
621
|
-
return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
|
|
622
|
-
}
|
|
623
|
-
external = false;
|
|
624
|
-
if (Ctor.modulo == 9) {
|
|
625
|
-
q = divide(x, y.abs(), 0, 3, 1);
|
|
626
|
-
q.s *= y.s;
|
|
627
|
-
} else {
|
|
628
|
-
q = divide(x, y, 0, Ctor.modulo, 1);
|
|
629
|
-
}
|
|
630
|
-
q = q.times(y);
|
|
631
|
-
external = true;
|
|
632
|
-
return x.minus(q);
|
|
633
|
-
};
|
|
634
|
-
P.naturalExponential = P.exp = function() {
|
|
635
|
-
return naturalExponential(this);
|
|
636
|
-
};
|
|
637
|
-
P.naturalLogarithm = P.ln = function() {
|
|
638
|
-
return naturalLogarithm(this);
|
|
639
|
-
};
|
|
640
|
-
P.negated = P.neg = function() {
|
|
641
|
-
var x = new this.constructor(this);
|
|
642
|
-
x.s = -x.s;
|
|
643
|
-
return finalise(x);
|
|
644
|
-
};
|
|
645
|
-
P.plus = P.add = function(y) {
|
|
646
|
-
var carry, d, e, i, k, len, pr, rm, xd, yd, x = this, Ctor = x.constructor;
|
|
647
|
-
y = new Ctor(y);
|
|
648
|
-
if (!x.d || !y.d) {
|
|
649
|
-
if (!x.s || !y.s)
|
|
650
|
-
y = new Ctor(NaN);
|
|
651
|
-
else if (!x.d)
|
|
652
|
-
y = new Ctor(y.d || x.s === y.s ? x : NaN);
|
|
653
|
-
return y;
|
|
654
|
-
}
|
|
655
|
-
if (x.s != y.s) {
|
|
656
|
-
y.s = -y.s;
|
|
657
|
-
return x.minus(y);
|
|
658
|
-
}
|
|
659
|
-
xd = x.d;
|
|
660
|
-
yd = y.d;
|
|
661
|
-
pr = Ctor.precision;
|
|
662
|
-
rm = Ctor.rounding;
|
|
663
|
-
if (!xd[0] || !yd[0]) {
|
|
664
|
-
if (!yd[0])
|
|
665
|
-
y = new Ctor(x);
|
|
666
|
-
return external ? finalise(y, pr, rm) : y;
|
|
667
|
-
}
|
|
668
|
-
k = mathfloor(x.e / LOG_BASE);
|
|
669
|
-
e = mathfloor(y.e / LOG_BASE);
|
|
670
|
-
xd = xd.slice();
|
|
671
|
-
i = k - e;
|
|
672
|
-
if (i) {
|
|
673
|
-
if (i < 0) {
|
|
674
|
-
d = xd;
|
|
675
|
-
i = -i;
|
|
676
|
-
len = yd.length;
|
|
677
|
-
} else {
|
|
678
|
-
d = yd;
|
|
679
|
-
e = k;
|
|
680
|
-
len = xd.length;
|
|
681
|
-
}
|
|
682
|
-
k = Math.ceil(pr / LOG_BASE);
|
|
683
|
-
len = k > len ? k + 1 : len + 1;
|
|
684
|
-
if (i > len) {
|
|
685
|
-
i = len;
|
|
686
|
-
d.length = 1;
|
|
687
|
-
}
|
|
688
|
-
d.reverse();
|
|
689
|
-
for (; i--; )
|
|
690
|
-
d.push(0);
|
|
691
|
-
d.reverse();
|
|
692
|
-
}
|
|
693
|
-
len = xd.length;
|
|
694
|
-
i = yd.length;
|
|
695
|
-
if (len - i < 0) {
|
|
696
|
-
i = len;
|
|
697
|
-
d = yd;
|
|
698
|
-
yd = xd;
|
|
699
|
-
xd = d;
|
|
700
|
-
}
|
|
701
|
-
for (carry = 0; i; ) {
|
|
702
|
-
carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
|
|
703
|
-
xd[i] %= BASE;
|
|
704
|
-
}
|
|
705
|
-
if (carry) {
|
|
706
|
-
xd.unshift(carry);
|
|
707
|
-
++e;
|
|
708
|
-
}
|
|
709
|
-
for (len = xd.length; xd[--len] == 0; )
|
|
710
|
-
xd.pop();
|
|
711
|
-
y.d = xd;
|
|
712
|
-
y.e = getBase10Exponent(xd, e);
|
|
713
|
-
return external ? finalise(y, pr, rm) : y;
|
|
714
|
-
};
|
|
715
|
-
P.precision = P.sd = function(z) {
|
|
716
|
-
var k, x = this;
|
|
717
|
-
if (z !== void 0 && z !== !!z && z !== 1 && z !== 0)
|
|
718
|
-
throw Error(invalidArgument + z);
|
|
719
|
-
if (x.d) {
|
|
720
|
-
k = getPrecision(x.d);
|
|
721
|
-
if (z && x.e + 1 > k)
|
|
722
|
-
k = x.e + 1;
|
|
723
|
-
} else {
|
|
724
|
-
k = NaN;
|
|
725
|
-
}
|
|
726
|
-
return k;
|
|
727
|
-
};
|
|
728
|
-
P.round = function() {
|
|
729
|
-
var x = this, Ctor = x.constructor;
|
|
730
|
-
return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
|
|
731
|
-
};
|
|
732
|
-
P.sine = P.sin = function() {
|
|
733
|
-
var pr, rm, x = this, Ctor = x.constructor;
|
|
734
|
-
if (!x.isFinite())
|
|
735
|
-
return new Ctor(NaN);
|
|
736
|
-
if (x.isZero())
|
|
737
|
-
return new Ctor(x);
|
|
738
|
-
pr = Ctor.precision;
|
|
739
|
-
rm = Ctor.rounding;
|
|
740
|
-
Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
|
|
741
|
-
Ctor.rounding = 1;
|
|
742
|
-
x = sine(Ctor, toLessThanHalfPi(Ctor, x));
|
|
743
|
-
Ctor.precision = pr;
|
|
744
|
-
Ctor.rounding = rm;
|
|
745
|
-
return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
|
|
746
|
-
};
|
|
747
|
-
P.squareRoot = P.sqrt = function() {
|
|
748
|
-
var m, n, sd, r, rep, t, x = this, d = x.d, e = x.e, s = x.s, Ctor = x.constructor;
|
|
749
|
-
if (s !== 1 || !d || !d[0]) {
|
|
750
|
-
return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
|
|
751
|
-
}
|
|
752
|
-
external = false;
|
|
753
|
-
s = Math.sqrt(+x);
|
|
754
|
-
if (s == 0 || s == 1 / 0) {
|
|
755
|
-
n = digitsToString(d);
|
|
756
|
-
if ((n.length + e) % 2 == 0)
|
|
757
|
-
n += "0";
|
|
758
|
-
s = Math.sqrt(n);
|
|
759
|
-
e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
|
|
760
|
-
if (s == 1 / 0) {
|
|
761
|
-
n = "5e" + e;
|
|
762
|
-
} else {
|
|
763
|
-
n = s.toExponential();
|
|
764
|
-
n = n.slice(0, n.indexOf("e") + 1) + e;
|
|
765
|
-
}
|
|
766
|
-
r = new Ctor(n);
|
|
767
|
-
} else {
|
|
768
|
-
r = new Ctor(s.toString());
|
|
769
|
-
}
|
|
770
|
-
sd = (e = Ctor.precision) + 3;
|
|
771
|
-
for (; ; ) {
|
|
772
|
-
t = r;
|
|
773
|
-
r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
|
|
774
|
-
if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
|
|
775
|
-
n = n.slice(sd - 3, sd + 1);
|
|
776
|
-
if (n == "9999" || !rep && n == "4999") {
|
|
777
|
-
if (!rep) {
|
|
778
|
-
finalise(t, e + 1, 0);
|
|
779
|
-
if (t.times(t).eq(x)) {
|
|
780
|
-
r = t;
|
|
781
|
-
break;
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
sd += 4;
|
|
785
|
-
rep = 1;
|
|
786
|
-
} else {
|
|
787
|
-
if (!+n || !+n.slice(1) && n.charAt(0) == "5") {
|
|
788
|
-
finalise(r, e + 1, 1);
|
|
789
|
-
m = !r.times(r).eq(x);
|
|
790
|
-
}
|
|
791
|
-
break;
|
|
173
|
+
if (value === -Infinity) {
|
|
174
|
+
this._mantissa = 0n;
|
|
175
|
+
this._exponent = 0;
|
|
176
|
+
this._special = SpecialValue.NEGATIVE_INFINITY;
|
|
177
|
+
this._negativeZero = false;
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (value === 0) {
|
|
181
|
+
this._mantissa = 0n;
|
|
182
|
+
this._exponent = 0;
|
|
183
|
+
this._special = SpecialValue.NONE;
|
|
184
|
+
this._negativeZero = Object.is(value, -0);
|
|
185
|
+
return;
|
|
792
186
|
}
|
|
187
|
+
value = String(value);
|
|
793
188
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
819
|
-
return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd ? NaN : !xd || !yd ? y.s / 0 : y.s * 0);
|
|
820
|
-
}
|
|
821
|
-
e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
|
|
822
|
-
xdL = xd.length;
|
|
823
|
-
ydL = yd.length;
|
|
824
|
-
if (xdL < ydL) {
|
|
825
|
-
r = xd;
|
|
826
|
-
xd = yd;
|
|
827
|
-
yd = r;
|
|
828
|
-
rL = xdL;
|
|
829
|
-
xdL = ydL;
|
|
830
|
-
ydL = rL;
|
|
831
|
-
}
|
|
832
|
-
r = [];
|
|
833
|
-
rL = xdL + ydL;
|
|
834
|
-
for (i = rL; i--; )
|
|
835
|
-
r.push(0);
|
|
836
|
-
for (i = ydL; --i >= 0; ) {
|
|
837
|
-
carry = 0;
|
|
838
|
-
for (k = xdL + i; k > i; ) {
|
|
839
|
-
t = r[k] + yd[i] * xd[k - i - 1] + carry;
|
|
840
|
-
r[k--] = t % BASE | 0;
|
|
841
|
-
carry = t / BASE | 0;
|
|
189
|
+
const parsed = parseDecimalString(value);
|
|
190
|
+
this._mantissa = parsed.mantissa;
|
|
191
|
+
this._exponent = parsed.exponent;
|
|
192
|
+
this._special = parsed.special;
|
|
193
|
+
this._negativeZero = parsed.negativeZero;
|
|
194
|
+
}
|
|
195
|
+
// Private constructor for internal use
|
|
196
|
+
static _create(mantissa, exponent, special, negativeZero) {
|
|
197
|
+
const bd = Object.create(_BigDecimal.prototype);
|
|
198
|
+
bd._mantissa = mantissa;
|
|
199
|
+
bd._exponent = exponent;
|
|
200
|
+
bd._special = special;
|
|
201
|
+
bd._negativeZero = negativeZero;
|
|
202
|
+
return bd;
|
|
203
|
+
}
|
|
204
|
+
// Auto-coerce to BigDecimal for decimal.js compat
|
|
205
|
+
static _coerce(v) {
|
|
206
|
+
return v instanceof _BigDecimal ? v : new _BigDecimal(v);
|
|
207
|
+
}
|
|
208
|
+
// --- Arithmetic ---
|
|
209
|
+
times(y) {
|
|
210
|
+
const other = _BigDecimal._coerce(y);
|
|
211
|
+
if (this._special || other._special) {
|
|
212
|
+
return this._specialArith(other, "times");
|
|
842
213
|
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
r.pop();
|
|
847
|
-
if (carry)
|
|
848
|
-
++e;
|
|
849
|
-
else
|
|
850
|
-
r.shift();
|
|
851
|
-
y.d = r;
|
|
852
|
-
y.e = getBase10Exponent(r, e);
|
|
853
|
-
return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
|
|
854
|
-
};
|
|
855
|
-
P.toBinary = function(sd, rm) {
|
|
856
|
-
return toStringBinary(this, 2, sd, rm);
|
|
857
|
-
};
|
|
858
|
-
P.toDecimalPlaces = P.toDP = function(dp, rm) {
|
|
859
|
-
var x = this, Ctor = x.constructor;
|
|
860
|
-
x = new Ctor(x);
|
|
861
|
-
if (dp === void 0)
|
|
862
|
-
return x;
|
|
863
|
-
checkInt32(dp, 0, MAX_DIGITS);
|
|
864
|
-
if (rm === void 0)
|
|
865
|
-
rm = Ctor.rounding;
|
|
866
|
-
else
|
|
867
|
-
checkInt32(rm, 0, 8);
|
|
868
|
-
return finalise(x, dp + x.e + 1, rm);
|
|
869
|
-
};
|
|
870
|
-
P.toExponential = function(dp, rm) {
|
|
871
|
-
var str, x = this, Ctor = x.constructor;
|
|
872
|
-
if (dp === void 0) {
|
|
873
|
-
str = finiteToString(x, true);
|
|
874
|
-
} else {
|
|
875
|
-
checkInt32(dp, 0, MAX_DIGITS);
|
|
876
|
-
if (rm === void 0)
|
|
877
|
-
rm = Ctor.rounding;
|
|
878
|
-
else
|
|
879
|
-
checkInt32(rm, 0, 8);
|
|
880
|
-
x = finalise(new Ctor(x), dp + 1, rm);
|
|
881
|
-
str = finiteToString(x, true, dp + 1);
|
|
882
|
-
}
|
|
883
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
884
|
-
};
|
|
885
|
-
P.toFixed = function(dp, rm) {
|
|
886
|
-
var str, y, x = this, Ctor = x.constructor;
|
|
887
|
-
if (dp === void 0) {
|
|
888
|
-
str = finiteToString(x);
|
|
889
|
-
} else {
|
|
890
|
-
checkInt32(dp, 0, MAX_DIGITS);
|
|
891
|
-
if (rm === void 0)
|
|
892
|
-
rm = Ctor.rounding;
|
|
893
|
-
else
|
|
894
|
-
checkInt32(rm, 0, 8);
|
|
895
|
-
y = finalise(new Ctor(x), dp + x.e + 1, rm);
|
|
896
|
-
str = finiteToString(y, false, dp + y.e + 1);
|
|
897
|
-
}
|
|
898
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
899
|
-
};
|
|
900
|
-
P.toFraction = function(maxD) {
|
|
901
|
-
var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r, x = this, xd = x.d, Ctor = x.constructor;
|
|
902
|
-
if (!xd)
|
|
903
|
-
return new Ctor(x);
|
|
904
|
-
n1 = d0 = new Ctor(1);
|
|
905
|
-
d1 = n0 = new Ctor(0);
|
|
906
|
-
d = new Ctor(d1);
|
|
907
|
-
e = d.e = getPrecision(xd) - x.e - 1;
|
|
908
|
-
k = e % LOG_BASE;
|
|
909
|
-
d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
|
|
910
|
-
if (maxD == null) {
|
|
911
|
-
maxD = e > 0 ? d : n1;
|
|
912
|
-
} else {
|
|
913
|
-
n = new Ctor(maxD);
|
|
914
|
-
if (!n.isInt() || n.lt(n1))
|
|
915
|
-
throw Error(invalidArgument + n);
|
|
916
|
-
maxD = n.gt(d) ? e > 0 ? d : n1 : n;
|
|
917
|
-
}
|
|
918
|
-
external = false;
|
|
919
|
-
n = new Ctor(digitsToString(xd));
|
|
920
|
-
pr = Ctor.precision;
|
|
921
|
-
Ctor.precision = e = xd.length * LOG_BASE * 2;
|
|
922
|
-
for (; ; ) {
|
|
923
|
-
q = divide(n, d, 0, 1, 1);
|
|
924
|
-
d2 = d0.plus(q.times(d1));
|
|
925
|
-
if (d2.cmp(maxD) == 1)
|
|
926
|
-
break;
|
|
927
|
-
d0 = d1;
|
|
928
|
-
d1 = d2;
|
|
929
|
-
d2 = n1;
|
|
930
|
-
n1 = n0.plus(q.times(d2));
|
|
931
|
-
n0 = d2;
|
|
932
|
-
d2 = d;
|
|
933
|
-
d = n.minus(q.times(d2));
|
|
934
|
-
n = d2;
|
|
935
|
-
}
|
|
936
|
-
d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
|
|
937
|
-
n0 = n0.plus(d2.times(n1));
|
|
938
|
-
d0 = d0.plus(d2.times(d1));
|
|
939
|
-
n0.s = n1.s = x.s;
|
|
940
|
-
r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0];
|
|
941
|
-
Ctor.precision = pr;
|
|
942
|
-
external = true;
|
|
943
|
-
return r;
|
|
944
|
-
};
|
|
945
|
-
P.toHexadecimal = P.toHex = function(sd, rm) {
|
|
946
|
-
return toStringBinary(this, 16, sd, rm);
|
|
947
|
-
};
|
|
948
|
-
P.toNearest = function(y, rm) {
|
|
949
|
-
var x = this, Ctor = x.constructor;
|
|
950
|
-
x = new Ctor(x);
|
|
951
|
-
if (y == null) {
|
|
952
|
-
if (!x.d)
|
|
953
|
-
return x;
|
|
954
|
-
y = new Ctor(1);
|
|
955
|
-
rm = Ctor.rounding;
|
|
956
|
-
} else {
|
|
957
|
-
y = new Ctor(y);
|
|
958
|
-
if (rm === void 0) {
|
|
959
|
-
rm = Ctor.rounding;
|
|
960
|
-
} else {
|
|
961
|
-
checkInt32(rm, 0, 8);
|
|
214
|
+
if (this._mantissa === 0n || other._mantissa === 0n) {
|
|
215
|
+
const negZero = this._isSignNegative() ? !other._isSignNegative() : other._isSignNegative();
|
|
216
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
|
|
962
217
|
}
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
218
|
+
const m = this._mantissa * other._mantissa;
|
|
219
|
+
const e = this._exponent + other._exponent;
|
|
220
|
+
const [nm, ne] = removeTrailingZeros(m, e);
|
|
221
|
+
return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
|
|
222
|
+
}
|
|
223
|
+
div(y) {
|
|
224
|
+
const other = _BigDecimal._coerce(y);
|
|
225
|
+
if (this._special || other._special) {
|
|
226
|
+
return this._specialArith(other, "div");
|
|
969
227
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
x = divide(x, y, 0, rm, 1).times(y);
|
|
974
|
-
external = true;
|
|
975
|
-
finalise(x);
|
|
976
|
-
} else {
|
|
977
|
-
y.s = x.s;
|
|
978
|
-
x = y;
|
|
979
|
-
}
|
|
980
|
-
return x;
|
|
981
|
-
};
|
|
982
|
-
P.toNumber = function() {
|
|
983
|
-
return +this;
|
|
984
|
-
};
|
|
985
|
-
P.toOctal = function(sd, rm) {
|
|
986
|
-
return toStringBinary(this, 8, sd, rm);
|
|
987
|
-
};
|
|
988
|
-
P.toPower = P.pow = function(y) {
|
|
989
|
-
var e, k, pr, r, rm, s, x = this, Ctor = x.constructor, yn = +(y = new Ctor(y));
|
|
990
|
-
if (!x.d || !y.d || !x.d[0] || !y.d[0])
|
|
991
|
-
return new Ctor(mathpow(+x, yn));
|
|
992
|
-
x = new Ctor(x);
|
|
993
|
-
if (x.eq(1))
|
|
994
|
-
return x;
|
|
995
|
-
pr = Ctor.precision;
|
|
996
|
-
rm = Ctor.rounding;
|
|
997
|
-
if (y.eq(1))
|
|
998
|
-
return finalise(x, pr, rm);
|
|
999
|
-
e = mathfloor(y.e / LOG_BASE);
|
|
1000
|
-
if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
|
|
1001
|
-
r = intPow(Ctor, x, k, pr);
|
|
1002
|
-
return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
|
|
1003
|
-
}
|
|
1004
|
-
s = x.s;
|
|
1005
|
-
if (s < 0) {
|
|
1006
|
-
if (e < y.d.length - 1)
|
|
1007
|
-
return new Ctor(NaN);
|
|
1008
|
-
if ((y.d[e] & 1) == 0)
|
|
1009
|
-
s = 1;
|
|
1010
|
-
if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
|
|
1011
|
-
x.s = s;
|
|
1012
|
-
return x;
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
k = mathpow(+x, yn);
|
|
1016
|
-
e = k == 0 || !isFinite(k) ? mathfloor(yn * (Math.log("0." + digitsToString(x.d)) / Math.LN10 + x.e + 1)) : new Ctor(k + "").e;
|
|
1017
|
-
if (e > Ctor.maxE + 1 || e < Ctor.minE - 1)
|
|
1018
|
-
return new Ctor(e > 0 ? s / 0 : 0);
|
|
1019
|
-
external = false;
|
|
1020
|
-
Ctor.rounding = x.s = 1;
|
|
1021
|
-
k = Math.min(12, (e + "").length);
|
|
1022
|
-
r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
|
|
1023
|
-
if (r.d) {
|
|
1024
|
-
r = finalise(r, pr + 5, 1);
|
|
1025
|
-
if (checkRoundingDigits(r.d, pr, rm)) {
|
|
1026
|
-
e = pr + 10;
|
|
1027
|
-
r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
|
|
1028
|
-
if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) {
|
|
1029
|
-
r = finalise(r, pr + 1, 0);
|
|
228
|
+
if (other._mantissa === 0n) {
|
|
229
|
+
if (this._mantissa === 0n) {
|
|
230
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
|
|
1030
231
|
}
|
|
232
|
+
const neg = this._isSignNegative() !== other._isSignNegative();
|
|
233
|
+
return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false);
|
|
1031
234
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
Ctor.rounding = rm;
|
|
1036
|
-
return finalise(r, pr, rm);
|
|
1037
|
-
};
|
|
1038
|
-
P.toPrecision = function(sd, rm) {
|
|
1039
|
-
var str, x = this, Ctor = x.constructor;
|
|
1040
|
-
if (sd === void 0) {
|
|
1041
|
-
str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
1042
|
-
} else {
|
|
1043
|
-
checkInt32(sd, 1, MAX_DIGITS);
|
|
1044
|
-
if (rm === void 0)
|
|
1045
|
-
rm = Ctor.rounding;
|
|
1046
|
-
else
|
|
1047
|
-
checkInt32(rm, 0, 8);
|
|
1048
|
-
x = finalise(new Ctor(x), sd, rm);
|
|
1049
|
-
str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
|
|
1050
|
-
}
|
|
1051
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
1052
|
-
};
|
|
1053
|
-
P.toSignificantDigits = P.toSD = function(sd, rm) {
|
|
1054
|
-
var x = this, Ctor = x.constructor;
|
|
1055
|
-
if (sd === void 0) {
|
|
1056
|
-
sd = Ctor.precision;
|
|
1057
|
-
rm = Ctor.rounding;
|
|
1058
|
-
} else {
|
|
1059
|
-
checkInt32(sd, 1, MAX_DIGITS);
|
|
1060
|
-
if (rm === void 0)
|
|
1061
|
-
rm = Ctor.rounding;
|
|
1062
|
-
else
|
|
1063
|
-
checkInt32(rm, 0, 8);
|
|
1064
|
-
}
|
|
1065
|
-
return finalise(new Ctor(x), sd, rm);
|
|
1066
|
-
};
|
|
1067
|
-
P.toString = function() {
|
|
1068
|
-
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
1069
|
-
return x.isNeg() && !x.isZero() ? "-" + str : str;
|
|
1070
|
-
};
|
|
1071
|
-
P.truncated = P.trunc = function() {
|
|
1072
|
-
return finalise(new this.constructor(this), this.e + 1, 1);
|
|
1073
|
-
};
|
|
1074
|
-
P.valueOf = P.toJSON = function() {
|
|
1075
|
-
var x = this, Ctor = x.constructor, str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
|
|
1076
|
-
return x.isNeg() ? "-" + str : str;
|
|
1077
|
-
};
|
|
1078
|
-
function digitsToString(d) {
|
|
1079
|
-
var i, k, ws, indexOfLastWord = d.length - 1, str = "", w = d[0];
|
|
1080
|
-
if (indexOfLastWord > 0) {
|
|
1081
|
-
str += w;
|
|
1082
|
-
for (i = 1; i < indexOfLastWord; i++) {
|
|
1083
|
-
ws = d[i] + "";
|
|
1084
|
-
k = LOG_BASE - ws.length;
|
|
1085
|
-
if (k)
|
|
1086
|
-
str += getZeroString(k);
|
|
1087
|
-
str += ws;
|
|
235
|
+
if (this._mantissa === 0n) {
|
|
236
|
+
const negZero = this._isSignNegative() !== other._isSignNegative();
|
|
237
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
|
|
1088
238
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
return str + w;
|
|
1100
|
-
}
|
|
1101
|
-
function checkInt32(i, min2, max2) {
|
|
1102
|
-
if (i !== ~~i || i < min2 || i > max2) {
|
|
1103
|
-
throw Error(invalidArgument + i);
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
function checkRoundingDigits(d, i, rm, repeating) {
|
|
1107
|
-
var di, k, r, rd;
|
|
1108
|
-
for (k = d[0]; k >= 10; k /= 10)
|
|
1109
|
-
--i;
|
|
1110
|
-
if (--i < 0) {
|
|
1111
|
-
i += LOG_BASE;
|
|
1112
|
-
di = 0;
|
|
1113
|
-
} else {
|
|
1114
|
-
di = Math.ceil((i + 1) / LOG_BASE);
|
|
1115
|
-
i %= LOG_BASE;
|
|
1116
|
-
}
|
|
1117
|
-
k = mathpow(10, LOG_BASE - i);
|
|
1118
|
-
rd = d[di] % k | 0;
|
|
1119
|
-
if (repeating == null) {
|
|
1120
|
-
if (i < 3) {
|
|
1121
|
-
if (i == 0)
|
|
1122
|
-
rd = rd / 100 | 0;
|
|
1123
|
-
else if (i == 1)
|
|
1124
|
-
rd = rd / 10 | 0;
|
|
1125
|
-
r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 5e4 || rd == 0;
|
|
1126
|
-
} else {
|
|
1127
|
-
r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 || (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
|
|
239
|
+
const scaledNumerator = this._mantissa * bigintPow10(DIV_PRECISION);
|
|
240
|
+
const quotient = scaledNumerator / other._mantissa;
|
|
241
|
+
const newExponent = this._exponent - other._exponent - DIV_PRECISION;
|
|
242
|
+
const [nm, ne] = removeTrailingZeros(quotient, newExponent);
|
|
243
|
+
return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
|
|
244
|
+
}
|
|
245
|
+
plus(y) {
|
|
246
|
+
const other = _BigDecimal._coerce(y);
|
|
247
|
+
if (this._special || other._special) {
|
|
248
|
+
return this._specialArith(other, "plus");
|
|
1128
249
|
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
rd = rd / 1e3 | 0;
|
|
1133
|
-
else if (i == 1)
|
|
1134
|
-
rd = rd / 100 | 0;
|
|
1135
|
-
else if (i == 2)
|
|
1136
|
-
rd = rd / 10 | 0;
|
|
1137
|
-
r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
|
|
1138
|
-
} else {
|
|
1139
|
-
r = ((repeating || rm < 4) && rd + 1 == k || !repeating && rm > 3 && rd + 1 == k / 2) && (d[di + 1] / k / 1e3 | 0) == mathpow(10, i - 3) - 1;
|
|
250
|
+
if (this._mantissa === 0n && other._mantissa === 0n) {
|
|
251
|
+
const negZero = this._negativeZero && other._negativeZero;
|
|
252
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
|
|
1140
253
|
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
254
|
+
if (this._mantissa === 0n)
|
|
255
|
+
return other;
|
|
256
|
+
if (other._mantissa === 0n)
|
|
257
|
+
return this;
|
|
258
|
+
let m1 = this._mantissa;
|
|
259
|
+
let m2 = other._mantissa;
|
|
260
|
+
const e1 = this._exponent;
|
|
261
|
+
const e2 = other._exponent;
|
|
262
|
+
const minE = Math.min(e1, e2);
|
|
263
|
+
if (e1 > minE)
|
|
264
|
+
m1 *= bigintPow10(e1 - minE);
|
|
265
|
+
if (e2 > minE)
|
|
266
|
+
m2 *= bigintPow10(e2 - minE);
|
|
267
|
+
const sum = m1 + m2;
|
|
268
|
+
if (sum === 0n) {
|
|
269
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NONE, false);
|
|
1157
270
|
}
|
|
271
|
+
const [nm, ne] = removeTrailingZeros(sum, minE);
|
|
272
|
+
return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
|
|
1158
273
|
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
function cosine(Ctor, x) {
|
|
1162
|
-
var k, len, y;
|
|
1163
|
-
if (x.isZero())
|
|
1164
|
-
return x;
|
|
1165
|
-
len = x.d.length;
|
|
1166
|
-
if (len < 32) {
|
|
1167
|
-
k = Math.ceil(len / 3);
|
|
1168
|
-
y = (1 / tinyPow(4, k)).toString();
|
|
1169
|
-
} else {
|
|
1170
|
-
k = 16;
|
|
1171
|
-
y = "2.3283064365386962890625e-10";
|
|
1172
|
-
}
|
|
1173
|
-
Ctor.precision += k;
|
|
1174
|
-
x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
|
|
1175
|
-
for (var i = k; i--; ) {
|
|
1176
|
-
var cos2x = x.times(x);
|
|
1177
|
-
x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
|
|
274
|
+
minus(y) {
|
|
275
|
+
return this.plus(_BigDecimal._coerce(y).negated());
|
|
1178
276
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
if (carry)
|
|
1191
|
-
x.unshift(carry);
|
|
1192
|
-
return x;
|
|
1193
|
-
}
|
|
1194
|
-
function compare(a, b, aL, bL) {
|
|
1195
|
-
var i, r;
|
|
1196
|
-
if (aL != bL) {
|
|
1197
|
-
r = aL > bL ? 1 : -1;
|
|
1198
|
-
} else {
|
|
1199
|
-
for (i = r = 0; i < aL; i++) {
|
|
1200
|
-
if (a[i] != b[i]) {
|
|
1201
|
-
r = a[i] > b[i] ? 1 : -1;
|
|
1202
|
-
break;
|
|
1203
|
-
}
|
|
277
|
+
mod(y) {
|
|
278
|
+
const other = _BigDecimal._coerce(y);
|
|
279
|
+
if (this._special || other._special) {
|
|
280
|
+
if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN) {
|
|
281
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
|
|
282
|
+
}
|
|
283
|
+
if (this._special === SpecialValue.POSITIVE_INFINITY || this._special === SpecialValue.NEGATIVE_INFINITY) {
|
|
284
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
|
|
285
|
+
}
|
|
286
|
+
if (other._special === SpecialValue.POSITIVE_INFINITY || other._special === SpecialValue.NEGATIVE_INFINITY) {
|
|
287
|
+
return this;
|
|
1204
288
|
}
|
|
1205
289
|
}
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
function subtract(a, b, aL, base) {
|
|
1209
|
-
var i = 0;
|
|
1210
|
-
for (; aL--; ) {
|
|
1211
|
-
a[aL] -= i;
|
|
1212
|
-
i = a[aL] < b[aL] ? 1 : 0;
|
|
1213
|
-
a[aL] = i * base + a[aL] - b[aL];
|
|
290
|
+
if (other._mantissa === 0n) {
|
|
291
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
|
|
1214
292
|
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
}
|
|
1218
|
-
return function(x, y, pr, rm, dp, base) {
|
|
1219
|
-
var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0, yL, yz, Ctor = x.constructor, sign2 = x.s == y.s ? 1 : -1, xd = x.d, yd = y.d;
|
|
1220
|
-
if (!xd || !xd[0] || !yd || !yd[0]) {
|
|
1221
|
-
return new Ctor(
|
|
1222
|
-
// Return NaN if either NaN, or both Infinity or 0.
|
|
1223
|
-
!x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN : (
|
|
1224
|
-
// Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
|
|
1225
|
-
xd && xd[0] == 0 || !yd ? sign2 * 0 : sign2 / 0
|
|
1226
|
-
)
|
|
1227
|
-
);
|
|
293
|
+
if (this._mantissa === 0n) {
|
|
294
|
+
return this;
|
|
1228
295
|
}
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
296
|
+
let m1 = this._mantissa;
|
|
297
|
+
let m2 = other._mantissa;
|
|
298
|
+
const e1 = this._exponent;
|
|
299
|
+
const e2 = other._exponent;
|
|
300
|
+
const minE = Math.min(e1, e2);
|
|
301
|
+
if (e1 > minE)
|
|
302
|
+
m1 *= bigintPow10(e1 - minE);
|
|
303
|
+
if (e2 > minE)
|
|
304
|
+
m2 *= bigintPow10(e2 - minE);
|
|
305
|
+
const remainder = m1 % m2;
|
|
306
|
+
if (remainder === 0n) {
|
|
307
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NONE, false);
|
|
1236
308
|
}
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
;
|
|
1243
|
-
if (
|
|
1244
|
-
|
|
1245
|
-
if (pr == null) {
|
|
1246
|
-
sd = pr = Ctor.precision;
|
|
1247
|
-
rm = Ctor.rounding;
|
|
1248
|
-
} else if (dp) {
|
|
1249
|
-
sd = pr + (x.e - y.e) + 1;
|
|
1250
|
-
} else {
|
|
1251
|
-
sd = pr;
|
|
309
|
+
const [nm, ne] = removeTrailingZeros(remainder, minE);
|
|
310
|
+
return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
|
|
311
|
+
}
|
|
312
|
+
abs() {
|
|
313
|
+
if (this._special === SpecialValue.NAN)
|
|
314
|
+
return this;
|
|
315
|
+
if (this._special === SpecialValue.NEGATIVE_INFINITY) {
|
|
316
|
+
return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false);
|
|
1252
317
|
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
k = 0;
|
|
1261
|
-
yd = yd[0];
|
|
1262
|
-
sd++;
|
|
1263
|
-
for (; (i < xL || k) && sd--; i++) {
|
|
1264
|
-
t = k * base + (xd[i] || 0);
|
|
1265
|
-
qd[i] = t / yd | 0;
|
|
1266
|
-
k = t % yd | 0;
|
|
1267
|
-
}
|
|
1268
|
-
more = k || i < xL;
|
|
1269
|
-
} else {
|
|
1270
|
-
k = base / (yd[0] + 1) | 0;
|
|
1271
|
-
if (k > 1) {
|
|
1272
|
-
yd = multiplyInteger(yd, k, base);
|
|
1273
|
-
xd = multiplyInteger(xd, k, base);
|
|
1274
|
-
yL = yd.length;
|
|
1275
|
-
xL = xd.length;
|
|
1276
|
-
}
|
|
1277
|
-
xi = yL;
|
|
1278
|
-
rem = xd.slice(0, yL);
|
|
1279
|
-
remL = rem.length;
|
|
1280
|
-
for (; remL < yL; )
|
|
1281
|
-
rem[remL++] = 0;
|
|
1282
|
-
yz = yd.slice();
|
|
1283
|
-
yz.unshift(0);
|
|
1284
|
-
yd0 = yd[0];
|
|
1285
|
-
if (yd[1] >= base / 2)
|
|
1286
|
-
++yd0;
|
|
1287
|
-
do {
|
|
1288
|
-
k = 0;
|
|
1289
|
-
cmp = compare(yd, rem, yL, remL);
|
|
1290
|
-
if (cmp < 0) {
|
|
1291
|
-
rem0 = rem[0];
|
|
1292
|
-
if (yL != remL)
|
|
1293
|
-
rem0 = rem0 * base + (rem[1] || 0);
|
|
1294
|
-
k = rem0 / yd0 | 0;
|
|
1295
|
-
if (k > 1) {
|
|
1296
|
-
if (k >= base)
|
|
1297
|
-
k = base - 1;
|
|
1298
|
-
prod = multiplyInteger(yd, k, base);
|
|
1299
|
-
prodL = prod.length;
|
|
1300
|
-
remL = rem.length;
|
|
1301
|
-
cmp = compare(prod, rem, prodL, remL);
|
|
1302
|
-
if (cmp == 1) {
|
|
1303
|
-
k--;
|
|
1304
|
-
subtract(prod, yL < prodL ? yz : yd, prodL, base);
|
|
1305
|
-
}
|
|
1306
|
-
} else {
|
|
1307
|
-
if (k == 0)
|
|
1308
|
-
cmp = k = 1;
|
|
1309
|
-
prod = yd.slice();
|
|
1310
|
-
}
|
|
1311
|
-
prodL = prod.length;
|
|
1312
|
-
if (prodL < remL)
|
|
1313
|
-
prod.unshift(0);
|
|
1314
|
-
subtract(rem, prod, remL, base);
|
|
1315
|
-
if (cmp == -1) {
|
|
1316
|
-
remL = rem.length;
|
|
1317
|
-
cmp = compare(yd, rem, yL, remL);
|
|
1318
|
-
if (cmp < 1) {
|
|
1319
|
-
k++;
|
|
1320
|
-
subtract(rem, yL < remL ? yz : yd, remL, base);
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
remL = rem.length;
|
|
1324
|
-
} else if (cmp === 0) {
|
|
1325
|
-
k++;
|
|
1326
|
-
rem = [0];
|
|
1327
|
-
}
|
|
1328
|
-
qd[i++] = k;
|
|
1329
|
-
if (cmp && rem[0]) {
|
|
1330
|
-
rem[remL++] = xd[xi] || 0;
|
|
1331
|
-
} else {
|
|
1332
|
-
rem = [xd[xi]];
|
|
1333
|
-
remL = 1;
|
|
1334
|
-
}
|
|
1335
|
-
} while ((xi++ < xL || rem[0] !== void 0) && sd--);
|
|
1336
|
-
more = rem[0] !== void 0;
|
|
1337
|
-
}
|
|
1338
|
-
if (!qd[0])
|
|
1339
|
-
qd.shift();
|
|
318
|
+
return _BigDecimal._create(bigintAbs(this._mantissa), this._exponent, this._special, false);
|
|
319
|
+
}
|
|
320
|
+
negated() {
|
|
321
|
+
if (this._special === SpecialValue.NAN)
|
|
322
|
+
return this;
|
|
323
|
+
if (this._special === SpecialValue.POSITIVE_INFINITY) {
|
|
324
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NEGATIVE_INFINITY, false);
|
|
1340
325
|
}
|
|
1341
|
-
if (
|
|
1342
|
-
|
|
1343
|
-
inexact = more;
|
|
1344
|
-
} else {
|
|
1345
|
-
for (i = 1, k = qd[0]; k >= 10; k /= 10)
|
|
1346
|
-
i++;
|
|
1347
|
-
q.e = i + e * logBase - 1;
|
|
1348
|
-
finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
|
|
326
|
+
if (this._special === SpecialValue.NEGATIVE_INFINITY) {
|
|
327
|
+
return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false);
|
|
1349
328
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
}();
|
|
1353
|
-
function finalise(x, sd, rm, isTruncated) {
|
|
1354
|
-
var digits, i, j, k, rd, roundUp, w, xd, xdi, Ctor = x.constructor;
|
|
1355
|
-
out:
|
|
1356
|
-
if (sd != null) {
|
|
1357
|
-
xd = x.d;
|
|
1358
|
-
if (!xd)
|
|
1359
|
-
return x;
|
|
1360
|
-
for (digits = 1, k = xd[0]; k >= 10; k /= 10)
|
|
1361
|
-
digits++;
|
|
1362
|
-
i = sd - digits;
|
|
1363
|
-
if (i < 0) {
|
|
1364
|
-
i += LOG_BASE;
|
|
1365
|
-
j = sd;
|
|
1366
|
-
w = xd[xdi = 0];
|
|
1367
|
-
rd = w / mathpow(10, digits - j - 1) % 10 | 0;
|
|
1368
|
-
} else {
|
|
1369
|
-
xdi = Math.ceil((i + 1) / LOG_BASE);
|
|
1370
|
-
k = xd.length;
|
|
1371
|
-
if (xdi >= k) {
|
|
1372
|
-
if (isTruncated) {
|
|
1373
|
-
for (; k++ <= xdi; )
|
|
1374
|
-
xd.push(0);
|
|
1375
|
-
w = rd = 0;
|
|
1376
|
-
digits = 1;
|
|
1377
|
-
i %= LOG_BASE;
|
|
1378
|
-
j = i - LOG_BASE + 1;
|
|
1379
|
-
} else {
|
|
1380
|
-
break out;
|
|
1381
|
-
}
|
|
1382
|
-
} else {
|
|
1383
|
-
w = k = xd[xdi];
|
|
1384
|
-
for (digits = 1; k >= 10; k /= 10)
|
|
1385
|
-
digits++;
|
|
1386
|
-
i %= LOG_BASE;
|
|
1387
|
-
j = i - LOG_BASE + digits;
|
|
1388
|
-
rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
isTruncated = isTruncated || sd < 0 || xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1));
|
|
1392
|
-
roundUp = rm < 4 ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
|
|
1393
|
-
(i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7));
|
|
1394
|
-
if (sd < 1 || !xd[0]) {
|
|
1395
|
-
xd.length = 0;
|
|
1396
|
-
if (roundUp) {
|
|
1397
|
-
sd -= x.e + 1;
|
|
1398
|
-
xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
|
|
1399
|
-
x.e = -sd || 0;
|
|
1400
|
-
} else {
|
|
1401
|
-
xd[0] = x.e = 0;
|
|
1402
|
-
}
|
|
1403
|
-
return x;
|
|
1404
|
-
}
|
|
1405
|
-
if (i == 0) {
|
|
1406
|
-
xd.length = xdi;
|
|
1407
|
-
k = 1;
|
|
1408
|
-
xdi--;
|
|
1409
|
-
} else {
|
|
1410
|
-
xd.length = xdi + 1;
|
|
1411
|
-
k = mathpow(10, LOG_BASE - i);
|
|
1412
|
-
xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
|
|
1413
|
-
}
|
|
1414
|
-
if (roundUp) {
|
|
1415
|
-
for (; ; ) {
|
|
1416
|
-
if (xdi == 0) {
|
|
1417
|
-
for (i = 1, j = xd[0]; j >= 10; j /= 10)
|
|
1418
|
-
i++;
|
|
1419
|
-
j = xd[0] += k;
|
|
1420
|
-
for (k = 1; j >= 10; j /= 10)
|
|
1421
|
-
k++;
|
|
1422
|
-
if (i != k) {
|
|
1423
|
-
x.e++;
|
|
1424
|
-
if (xd[0] == BASE)
|
|
1425
|
-
xd[0] = 1;
|
|
1426
|
-
}
|
|
1427
|
-
break;
|
|
1428
|
-
} else {
|
|
1429
|
-
xd[xdi] += k;
|
|
1430
|
-
if (xd[xdi] != BASE)
|
|
1431
|
-
break;
|
|
1432
|
-
xd[xdi--] = 0;
|
|
1433
|
-
k = 1;
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
for (i = xd.length; xd[--i] === 0; )
|
|
1438
|
-
xd.pop();
|
|
329
|
+
if (this._mantissa === 0n) {
|
|
330
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NONE, !this._negativeZero);
|
|
1439
331
|
}
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
332
|
+
return _BigDecimal._create(-this._mantissa, this._exponent, SpecialValue.NONE, false);
|
|
333
|
+
}
|
|
334
|
+
pow(n) {
|
|
335
|
+
if (this._special === SpecialValue.NAN)
|
|
336
|
+
return this;
|
|
337
|
+
if (n === 0)
|
|
338
|
+
return new _BigDecimal(1);
|
|
339
|
+
if (n < 0) {
|
|
340
|
+
return new _BigDecimal(1).div(this.pow(-n));
|
|
1447
341
|
}
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
if (!x.isFinite())
|
|
1453
|
-
return nonFiniteToString(x);
|
|
1454
|
-
var k, e = x.e, str = digitsToString(x.d), len = str.length;
|
|
1455
|
-
if (isExp) {
|
|
1456
|
-
if (sd && (k = sd - len) > 0) {
|
|
1457
|
-
str = str.charAt(0) + "." + str.slice(1) + getZeroString(k);
|
|
1458
|
-
} else if (len > 1) {
|
|
1459
|
-
str = str.charAt(0) + "." + str.slice(1);
|
|
342
|
+
if (this._special === SpecialValue.POSITIVE_INFINITY)
|
|
343
|
+
return this;
|
|
344
|
+
if (this._special === SpecialValue.NEGATIVE_INFINITY) {
|
|
345
|
+
return n % 2 === 0 ? _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false) : this;
|
|
1460
346
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
if (
|
|
1472
|
-
|
|
1473
|
-
if (
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
347
|
+
if (this._mantissa === 0n)
|
|
348
|
+
return new _BigDecimal(0);
|
|
349
|
+
const m = this._mantissa ** BigInt(n);
|
|
350
|
+
const e = this._exponent * n;
|
|
351
|
+
const [nm, ne] = removeTrailingZeros(m, e);
|
|
352
|
+
return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
|
|
353
|
+
}
|
|
354
|
+
floor() {
|
|
355
|
+
if (this._special !== SpecialValue.NONE)
|
|
356
|
+
return this;
|
|
357
|
+
if (this._mantissa === 0n)
|
|
358
|
+
return this;
|
|
359
|
+
if (this._exponent >= 0)
|
|
360
|
+
return this;
|
|
361
|
+
const divisor = bigintPow10(-this._exponent);
|
|
362
|
+
const m = this._mantissa;
|
|
363
|
+
let q = m / divisor;
|
|
364
|
+
if (m < 0n && m % divisor !== 0n) {
|
|
365
|
+
q -= 1n;
|
|
1477
366
|
}
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
function getBase10Exponent(digits, e) {
|
|
1482
|
-
var w = digits[0];
|
|
1483
|
-
for (e *= LOG_BASE; w >= 10; w /= 10)
|
|
1484
|
-
e++;
|
|
1485
|
-
return e;
|
|
1486
|
-
}
|
|
1487
|
-
function getLn10(Ctor, sd, pr) {
|
|
1488
|
-
if (sd > LN10_PRECISION) {
|
|
1489
|
-
external = true;
|
|
1490
|
-
if (pr)
|
|
1491
|
-
Ctor.precision = pr;
|
|
1492
|
-
throw Error(precisionLimitExceeded);
|
|
1493
|
-
}
|
|
1494
|
-
return finalise(new Ctor(LN10), sd, 1, true);
|
|
1495
|
-
}
|
|
1496
|
-
function getPi(Ctor, sd, rm) {
|
|
1497
|
-
if (sd > PI_PRECISION)
|
|
1498
|
-
throw Error(precisionLimitExceeded);
|
|
1499
|
-
return finalise(new Ctor(PI), sd, rm, true);
|
|
1500
|
-
}
|
|
1501
|
-
function getPrecision(digits) {
|
|
1502
|
-
var w = digits.length - 1, len = w * LOG_BASE + 1;
|
|
1503
|
-
w = digits[w];
|
|
1504
|
-
if (w) {
|
|
1505
|
-
for (; w % 10 == 0; w /= 10)
|
|
1506
|
-
len--;
|
|
1507
|
-
for (w = digits[0]; w >= 10; w /= 10)
|
|
1508
|
-
len++;
|
|
1509
|
-
}
|
|
1510
|
-
return len;
|
|
1511
|
-
}
|
|
1512
|
-
function getZeroString(k) {
|
|
1513
|
-
var zs = "";
|
|
1514
|
-
for (; k--; )
|
|
1515
|
-
zs += "0";
|
|
1516
|
-
return zs;
|
|
1517
|
-
}
|
|
1518
|
-
function intPow(Ctor, x, n, pr) {
|
|
1519
|
-
var isTruncated, r = new Ctor(1), k = Math.ceil(pr / LOG_BASE + 4);
|
|
1520
|
-
external = false;
|
|
1521
|
-
for (; ; ) {
|
|
1522
|
-
if (n % 2) {
|
|
1523
|
-
r = r.times(x);
|
|
1524
|
-
if (truncate(r.d, k))
|
|
1525
|
-
isTruncated = true;
|
|
367
|
+
if (q === 0n) {
|
|
368
|
+
const negZero = this._mantissa < 0n;
|
|
369
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
|
|
1526
370
|
}
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
371
|
+
const [nm, ne] = removeTrailingZeros(q, 0);
|
|
372
|
+
return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
|
|
373
|
+
}
|
|
374
|
+
ceil() {
|
|
375
|
+
if (this._special !== SpecialValue.NONE)
|
|
376
|
+
return this;
|
|
377
|
+
if (this._mantissa === 0n)
|
|
378
|
+
return this;
|
|
379
|
+
if (this._exponent >= 0)
|
|
380
|
+
return this;
|
|
381
|
+
const divisor = bigintPow10(-this._exponent);
|
|
382
|
+
const m = this._mantissa;
|
|
383
|
+
let q = m / divisor;
|
|
384
|
+
if (m > 0n && m % divisor !== 0n) {
|
|
385
|
+
q += 1n;
|
|
1533
386
|
}
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
}
|
|
1537
|
-
external = true;
|
|
1538
|
-
return r;
|
|
1539
|
-
}
|
|
1540
|
-
function isOdd(n) {
|
|
1541
|
-
return n.d[n.d.length - 1] & 1;
|
|
1542
|
-
}
|
|
1543
|
-
function maxOrMin(Ctor, args, n) {
|
|
1544
|
-
var k, y, x = new Ctor(args[0]), i = 0;
|
|
1545
|
-
for (; ++i < args.length; ) {
|
|
1546
|
-
y = new Ctor(args[i]);
|
|
1547
|
-
if (!y.s) {
|
|
1548
|
-
x = y;
|
|
1549
|
-
break;
|
|
387
|
+
if (q === 0n) {
|
|
388
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NONE, false);
|
|
1550
389
|
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
390
|
+
const [nm, ne] = removeTrailingZeros(q, 0);
|
|
391
|
+
return _BigDecimal._create(nm, ne, SpecialValue.NONE, false);
|
|
392
|
+
}
|
|
393
|
+
log(base) {
|
|
394
|
+
if (this._special === SpecialValue.NAN)
|
|
395
|
+
return this;
|
|
396
|
+
if (this._special === SpecialValue.NEGATIVE_INFINITY) {
|
|
397
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
|
|
1554
398
|
}
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
}
|
|
1558
|
-
function naturalExponential(x, sd) {
|
|
1559
|
-
var denominator, guard, j, pow2, sum2, t, wpr, rep = 0, i = 0, k = 0, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
|
|
1560
|
-
if (!x.d || !x.d[0] || x.e > 17) {
|
|
1561
|
-
return new Ctor(x.d ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0 : x.s ? x.s < 0 ? 0 : x : 0 / 0);
|
|
1562
|
-
}
|
|
1563
|
-
if (sd == null) {
|
|
1564
|
-
external = false;
|
|
1565
|
-
wpr = pr;
|
|
1566
|
-
} else {
|
|
1567
|
-
wpr = sd;
|
|
1568
|
-
}
|
|
1569
|
-
t = new Ctor(0.03125);
|
|
1570
|
-
while (x.e > -2) {
|
|
1571
|
-
x = x.times(t);
|
|
1572
|
-
k += 5;
|
|
1573
|
-
}
|
|
1574
|
-
guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
|
|
1575
|
-
wpr += guard;
|
|
1576
|
-
denominator = pow2 = sum2 = new Ctor(1);
|
|
1577
|
-
Ctor.precision = wpr;
|
|
1578
|
-
for (; ; ) {
|
|
1579
|
-
pow2 = finalise(pow2.times(x), wpr, 1);
|
|
1580
|
-
denominator = denominator.times(++i);
|
|
1581
|
-
t = sum2.plus(divide(pow2, denominator, wpr, 1));
|
|
1582
|
-
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
|
|
1583
|
-
j = k;
|
|
1584
|
-
while (j--)
|
|
1585
|
-
sum2 = finalise(sum2.times(sum2), wpr, 1);
|
|
1586
|
-
if (sd == null) {
|
|
1587
|
-
if (rep < 3 && checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
|
|
1588
|
-
Ctor.precision = wpr += 10;
|
|
1589
|
-
denominator = pow2 = t = new Ctor(1);
|
|
1590
|
-
i = 0;
|
|
1591
|
-
rep++;
|
|
1592
|
-
} else {
|
|
1593
|
-
return finalise(sum2, Ctor.precision = pr, rm, external = true);
|
|
1594
|
-
}
|
|
1595
|
-
} else {
|
|
1596
|
-
Ctor.precision = pr;
|
|
1597
|
-
return sum2;
|
|
1598
|
-
}
|
|
399
|
+
if (this._special === SpecialValue.POSITIVE_INFINITY) {
|
|
400
|
+
return _BigDecimal._create(0n, 0, SpecialValue.POSITIVE_INFINITY, false);
|
|
1599
401
|
}
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
}
|
|
1603
|
-
function naturalLogarithm(y, sd) {
|
|
1604
|
-
var c, c0, denominator, e, numerator, rep, sum2, t, wpr, x1, x2, n = 1, guard = 10, x = y, xd = x.d, Ctor = x.constructor, rm = Ctor.rounding, pr = Ctor.precision;
|
|
1605
|
-
if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
|
|
1606
|
-
return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
|
|
1607
|
-
}
|
|
1608
|
-
if (sd == null) {
|
|
1609
|
-
external = false;
|
|
1610
|
-
wpr = pr;
|
|
1611
|
-
} else {
|
|
1612
|
-
wpr = sd;
|
|
1613
|
-
}
|
|
1614
|
-
Ctor.precision = wpr += guard;
|
|
1615
|
-
c = digitsToString(xd);
|
|
1616
|
-
c0 = c.charAt(0);
|
|
1617
|
-
if (Math.abs(e = x.e) < 15e14) {
|
|
1618
|
-
while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
|
|
1619
|
-
x = x.times(y);
|
|
1620
|
-
c = digitsToString(x.d);
|
|
1621
|
-
c0 = c.charAt(0);
|
|
1622
|
-
n++;
|
|
402
|
+
if (this._mantissa < 0n) {
|
|
403
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
|
|
1623
404
|
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
x = new Ctor("0." + c);
|
|
1627
|
-
e++;
|
|
1628
|
-
} else {
|
|
1629
|
-
x = new Ctor(c0 + "." + c.slice(1));
|
|
405
|
+
if (this._mantissa === 0n) {
|
|
406
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NEGATIVE_INFINITY, false);
|
|
1630
407
|
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
x = naturalLogarithm(new Ctor(c0 + "." + c.slice(1)), wpr - guard).plus(t);
|
|
1634
|
-
Ctor.precision = pr;
|
|
1635
|
-
return sd == null ? finalise(x, pr, rm, external = true) : x;
|
|
1636
|
-
}
|
|
1637
|
-
x1 = x;
|
|
1638
|
-
sum2 = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
|
|
1639
|
-
x2 = finalise(x.times(x), wpr, 1);
|
|
1640
|
-
denominator = 3;
|
|
1641
|
-
for (; ; ) {
|
|
1642
|
-
numerator = finalise(numerator.times(x2), wpr, 1);
|
|
1643
|
-
t = sum2.plus(divide(numerator, new Ctor(denominator), wpr, 1));
|
|
1644
|
-
if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum2.d).slice(0, wpr)) {
|
|
1645
|
-
sum2 = sum2.times(2);
|
|
1646
|
-
if (e !== 0)
|
|
1647
|
-
sum2 = sum2.plus(getLn10(Ctor, wpr + 2, pr).times(e + ""));
|
|
1648
|
-
sum2 = divide(sum2, new Ctor(n), wpr, 1);
|
|
1649
|
-
if (sd == null) {
|
|
1650
|
-
if (checkRoundingDigits(sum2.d, wpr - guard, rm, rep)) {
|
|
1651
|
-
Ctor.precision = wpr += guard;
|
|
1652
|
-
t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
|
|
1653
|
-
x2 = finalise(x.times(x), wpr, 1);
|
|
1654
|
-
denominator = rep = 1;
|
|
1655
|
-
} else {
|
|
1656
|
-
return finalise(sum2, Ctor.precision = pr, rm, external = true);
|
|
1657
|
-
}
|
|
1658
|
-
} else {
|
|
1659
|
-
Ctor.precision = pr;
|
|
1660
|
-
return sum2;
|
|
1661
|
-
}
|
|
408
|
+
if (base === 10) {
|
|
409
|
+
return this._log10();
|
|
1662
410
|
}
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
str = str.replace(".", "");
|
|
1674
|
-
if ((i = str.search(/e/i)) > 0) {
|
|
1675
|
-
if (e < 0)
|
|
1676
|
-
e = i;
|
|
1677
|
-
e += +str.slice(i + 1);
|
|
1678
|
-
str = str.substring(0, i);
|
|
1679
|
-
} else if (e < 0) {
|
|
1680
|
-
e = str.length;
|
|
1681
|
-
}
|
|
1682
|
-
for (i = 0; str.charCodeAt(i) === 48; i++)
|
|
1683
|
-
;
|
|
1684
|
-
for (len = str.length; str.charCodeAt(len - 1) === 48; --len)
|
|
1685
|
-
;
|
|
1686
|
-
str = str.slice(i, len);
|
|
1687
|
-
if (str) {
|
|
1688
|
-
len -= i;
|
|
1689
|
-
x.e = e = e - i - 1;
|
|
1690
|
-
x.d = [];
|
|
1691
|
-
i = (e + 1) % LOG_BASE;
|
|
1692
|
-
if (e < 0)
|
|
1693
|
-
i += LOG_BASE;
|
|
1694
|
-
if (i < len) {
|
|
1695
|
-
if (i)
|
|
1696
|
-
x.d.push(+str.slice(0, i));
|
|
1697
|
-
for (len -= LOG_BASE; i < len; )
|
|
1698
|
-
x.d.push(+str.slice(i, i += LOG_BASE));
|
|
1699
|
-
str = str.slice(i);
|
|
1700
|
-
i = LOG_BASE - str.length;
|
|
411
|
+
const log10x = this._log10();
|
|
412
|
+
const log10b = new _BigDecimal(Math.log10(base));
|
|
413
|
+
return log10x.div(log10b);
|
|
414
|
+
}
|
|
415
|
+
_log10() {
|
|
416
|
+
const absMantissa = bigintAbs(this._mantissa);
|
|
417
|
+
const digits = digitCount(absMantissa);
|
|
418
|
+
let log10Mantissa;
|
|
419
|
+
if (digits <= 15) {
|
|
420
|
+
log10Mantissa = Math.log10(Number(absMantissa));
|
|
1701
421
|
} else {
|
|
1702
|
-
|
|
422
|
+
const shift = digits - 17;
|
|
423
|
+
const leading = absMantissa / bigintPow10(shift);
|
|
424
|
+
log10Mantissa = Math.log10(Number(leading)) + shift;
|
|
1703
425
|
}
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
426
|
+
const totalLog10 = log10Mantissa + this._exponent;
|
|
427
|
+
return new _BigDecimal(totalLog10);
|
|
428
|
+
}
|
|
429
|
+
// --- Comparison ---
|
|
430
|
+
eq(y) {
|
|
431
|
+
const other = _BigDecimal._coerce(y);
|
|
432
|
+
if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN)
|
|
433
|
+
return false;
|
|
434
|
+
if (this._special !== other._special)
|
|
435
|
+
return false;
|
|
436
|
+
if (this._special !== SpecialValue.NONE)
|
|
437
|
+
return true;
|
|
438
|
+
if (this._mantissa === 0n && other._mantissa === 0n)
|
|
439
|
+
return true;
|
|
440
|
+
return this._mantissa === other._mantissa && this._exponent === other._exponent;
|
|
441
|
+
}
|
|
442
|
+
_compareTo(other) {
|
|
443
|
+
if (this._special === SpecialValue.NAN || other._special === SpecialValue.NAN) {
|
|
444
|
+
return NaN;
|
|
1715
445
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
x.d = [0];
|
|
1719
|
-
}
|
|
1720
|
-
return x;
|
|
1721
|
-
}
|
|
1722
|
-
function parseOther(x, str) {
|
|
1723
|
-
var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
|
|
1724
|
-
if (str.indexOf("_") > -1) {
|
|
1725
|
-
str = str.replace(/(\d)_(?=\d)/g, "$1");
|
|
1726
|
-
if (isDecimal.test(str))
|
|
1727
|
-
return parseDecimal(x, str);
|
|
1728
|
-
} else if (str === "Infinity" || str === "NaN") {
|
|
1729
|
-
if (!+str)
|
|
1730
|
-
x.s = NaN;
|
|
1731
|
-
x.e = NaN;
|
|
1732
|
-
x.d = null;
|
|
1733
|
-
return x;
|
|
1734
|
-
}
|
|
1735
|
-
if (isHex.test(str)) {
|
|
1736
|
-
base = 16;
|
|
1737
|
-
str = str.toLowerCase();
|
|
1738
|
-
} else if (isBinary.test(str)) {
|
|
1739
|
-
base = 2;
|
|
1740
|
-
} else if (isOctal.test(str)) {
|
|
1741
|
-
base = 8;
|
|
1742
|
-
} else {
|
|
1743
|
-
throw Error(invalidArgument + str);
|
|
1744
|
-
}
|
|
1745
|
-
i = str.search(/p/i);
|
|
1746
|
-
if (i > 0) {
|
|
1747
|
-
p = +str.slice(i + 1);
|
|
1748
|
-
str = str.substring(2, i);
|
|
1749
|
-
} else {
|
|
1750
|
-
str = str.slice(2);
|
|
1751
|
-
}
|
|
1752
|
-
i = str.indexOf(".");
|
|
1753
|
-
isFloat = i >= 0;
|
|
1754
|
-
Ctor = x.constructor;
|
|
1755
|
-
if (isFloat) {
|
|
1756
|
-
str = str.replace(".", "");
|
|
1757
|
-
len = str.length;
|
|
1758
|
-
i = len - i;
|
|
1759
|
-
divisor = intPow(Ctor, new Ctor(base), i, i * 2);
|
|
1760
|
-
}
|
|
1761
|
-
xd = convertBase(str, base, BASE);
|
|
1762
|
-
xe = xd.length - 1;
|
|
1763
|
-
for (i = xe; xd[i] === 0; --i)
|
|
1764
|
-
xd.pop();
|
|
1765
|
-
if (i < 0)
|
|
1766
|
-
return new Ctor(x.s * 0);
|
|
1767
|
-
x.e = getBase10Exponent(xd, xe);
|
|
1768
|
-
x.d = xd;
|
|
1769
|
-
external = false;
|
|
1770
|
-
if (isFloat)
|
|
1771
|
-
x = divide(x, divisor, len * 4);
|
|
1772
|
-
if (p)
|
|
1773
|
-
x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
|
|
1774
|
-
external = true;
|
|
1775
|
-
return x;
|
|
1776
|
-
}
|
|
1777
|
-
function sine(Ctor, x) {
|
|
1778
|
-
var k, len = x.d.length;
|
|
1779
|
-
if (len < 3) {
|
|
1780
|
-
return x.isZero() ? x : taylorSeries(Ctor, 2, x, x);
|
|
1781
|
-
}
|
|
1782
|
-
k = 1.4 * Math.sqrt(len);
|
|
1783
|
-
k = k > 16 ? 16 : k | 0;
|
|
1784
|
-
x = x.times(1 / tinyPow(5, k));
|
|
1785
|
-
x = taylorSeries(Ctor, 2, x, x);
|
|
1786
|
-
var sin2_x, d5 = new Ctor(5), d16 = new Ctor(16), d20 = new Ctor(20);
|
|
1787
|
-
for (; k--; ) {
|
|
1788
|
-
sin2_x = x.times(x);
|
|
1789
|
-
x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
|
|
1790
|
-
}
|
|
1791
|
-
return x;
|
|
1792
|
-
}
|
|
1793
|
-
function taylorSeries(Ctor, n, x, y, isHyperbolic) {
|
|
1794
|
-
var j, t, u, x2, i = 1, pr = Ctor.precision, k = Math.ceil(pr / LOG_BASE);
|
|
1795
|
-
external = false;
|
|
1796
|
-
x2 = x.times(x);
|
|
1797
|
-
u = new Ctor(y);
|
|
1798
|
-
for (; ; ) {
|
|
1799
|
-
t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
1800
|
-
u = isHyperbolic ? y.plus(t) : y.minus(t);
|
|
1801
|
-
y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
|
|
1802
|
-
t = u.plus(y);
|
|
1803
|
-
if (t.d[k] !== void 0) {
|
|
1804
|
-
for (j = k; t.d[j] === u.d[j] && j--; )
|
|
1805
|
-
;
|
|
1806
|
-
if (j == -1)
|
|
1807
|
-
break;
|
|
446
|
+
if (this._special === SpecialValue.POSITIVE_INFINITY) {
|
|
447
|
+
return other._special === SpecialValue.POSITIVE_INFINITY ? 0 : 1;
|
|
1808
448
|
}
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
y = t;
|
|
1812
|
-
t = j;
|
|
1813
|
-
i++;
|
|
1814
|
-
}
|
|
1815
|
-
external = true;
|
|
1816
|
-
t.d.length = k + 1;
|
|
1817
|
-
return t;
|
|
1818
|
-
}
|
|
1819
|
-
function tinyPow(b, e) {
|
|
1820
|
-
var n = b;
|
|
1821
|
-
while (--e)
|
|
1822
|
-
n *= b;
|
|
1823
|
-
return n;
|
|
1824
|
-
}
|
|
1825
|
-
function toLessThanHalfPi(Ctor, x) {
|
|
1826
|
-
var t, isNeg = x.s < 0, pi = getPi(Ctor, Ctor.precision, 1), halfPi = pi.times(0.5);
|
|
1827
|
-
x = x.abs();
|
|
1828
|
-
if (x.lte(halfPi)) {
|
|
1829
|
-
quadrant = isNeg ? 4 : 1;
|
|
1830
|
-
return x;
|
|
1831
|
-
}
|
|
1832
|
-
t = x.divToInt(pi);
|
|
1833
|
-
if (t.isZero()) {
|
|
1834
|
-
quadrant = isNeg ? 3 : 2;
|
|
1835
|
-
} else {
|
|
1836
|
-
x = x.minus(t.times(pi));
|
|
1837
|
-
if (x.lte(halfPi)) {
|
|
1838
|
-
quadrant = isOdd(t) ? isNeg ? 2 : 3 : isNeg ? 4 : 1;
|
|
1839
|
-
return x;
|
|
449
|
+
if (this._special === SpecialValue.NEGATIVE_INFINITY) {
|
|
450
|
+
return other._special === SpecialValue.NEGATIVE_INFINITY ? 0 : -1;
|
|
1840
451
|
}
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
if (
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
if (
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
452
|
+
if (other._special === SpecialValue.POSITIVE_INFINITY)
|
|
453
|
+
return -1;
|
|
454
|
+
if (other._special === SpecialValue.NEGATIVE_INFINITY)
|
|
455
|
+
return 1;
|
|
456
|
+
const thisZero = this._mantissa === 0n;
|
|
457
|
+
const otherZero = other._mantissa === 0n;
|
|
458
|
+
if (thisZero && otherZero)
|
|
459
|
+
return 0;
|
|
460
|
+
if (thisZero)
|
|
461
|
+
return other._mantissa > 0n ? -1 : 1;
|
|
462
|
+
if (otherZero)
|
|
463
|
+
return this._mantissa > 0n ? 1 : -1;
|
|
464
|
+
const thisNeg = this._mantissa < 0n;
|
|
465
|
+
const otherNeg = other._mantissa < 0n;
|
|
466
|
+
if (thisNeg !== otherNeg)
|
|
467
|
+
return thisNeg ? -1 : 1;
|
|
468
|
+
let m1 = this._mantissa;
|
|
469
|
+
let m2 = other._mantissa;
|
|
470
|
+
const e1 = this._exponent;
|
|
471
|
+
const e2 = other._exponent;
|
|
472
|
+
const minE = Math.min(e1, e2);
|
|
473
|
+
if (e1 > minE)
|
|
474
|
+
m1 *= bigintPow10(e1 - minE);
|
|
475
|
+
if (e2 > minE)
|
|
476
|
+
m2 *= bigintPow10(e2 - minE);
|
|
477
|
+
if (m1 < m2)
|
|
478
|
+
return -1;
|
|
479
|
+
if (m1 > m2)
|
|
480
|
+
return 1;
|
|
481
|
+
return 0;
|
|
482
|
+
}
|
|
483
|
+
lessThan(y) {
|
|
484
|
+
const c = this._compareTo(_BigDecimal._coerce(y));
|
|
485
|
+
return c === -1;
|
|
486
|
+
}
|
|
487
|
+
greaterThan(y) {
|
|
488
|
+
const c = this._compareTo(_BigDecimal._coerce(y));
|
|
489
|
+
return c === 1;
|
|
490
|
+
}
|
|
491
|
+
lessThanOrEqualTo(y) {
|
|
492
|
+
const c = this._compareTo(_BigDecimal._coerce(y));
|
|
493
|
+
return c === 0 || c === -1;
|
|
494
|
+
}
|
|
495
|
+
greaterThanOrEqualTo(y) {
|
|
496
|
+
const c = this._compareTo(_BigDecimal._coerce(y));
|
|
497
|
+
return c === 0 || c === 1;
|
|
498
|
+
}
|
|
499
|
+
// --- Queries ---
|
|
500
|
+
isZero() {
|
|
501
|
+
return this._special === SpecialValue.NONE && this._mantissa === 0n;
|
|
502
|
+
}
|
|
503
|
+
isNaN() {
|
|
504
|
+
return this._special === SpecialValue.NAN;
|
|
505
|
+
}
|
|
506
|
+
isFinite() {
|
|
507
|
+
return this._special === SpecialValue.NONE;
|
|
508
|
+
}
|
|
509
|
+
isNegative() {
|
|
510
|
+
if (this._special === SpecialValue.NAN)
|
|
511
|
+
return false;
|
|
512
|
+
if (this._special === SpecialValue.NEGATIVE_INFINITY)
|
|
513
|
+
return true;
|
|
514
|
+
if (this._special === SpecialValue.POSITIVE_INFINITY)
|
|
515
|
+
return false;
|
|
516
|
+
if (this._mantissa === 0n)
|
|
517
|
+
return this._negativeZero;
|
|
518
|
+
return this._mantissa < 0n;
|
|
519
|
+
}
|
|
520
|
+
isPositive() {
|
|
521
|
+
if (this._special === SpecialValue.NAN)
|
|
522
|
+
return false;
|
|
523
|
+
if (this._special === SpecialValue.POSITIVE_INFINITY)
|
|
524
|
+
return true;
|
|
525
|
+
if (this._special === SpecialValue.NEGATIVE_INFINITY)
|
|
526
|
+
return false;
|
|
527
|
+
if (this._mantissa === 0n)
|
|
528
|
+
return !this._negativeZero;
|
|
529
|
+
return this._mantissa > 0n;
|
|
530
|
+
}
|
|
531
|
+
isInteger() {
|
|
532
|
+
if (this._special !== SpecialValue.NONE)
|
|
533
|
+
return false;
|
|
534
|
+
if (this._mantissa === 0n)
|
|
535
|
+
return true;
|
|
536
|
+
return this._exponent >= 0;
|
|
537
|
+
}
|
|
538
|
+
// --- Conversion ---
|
|
539
|
+
toJSON() {
|
|
540
|
+
return this.toString();
|
|
541
|
+
}
|
|
542
|
+
toNumber() {
|
|
543
|
+
if (this._special === SpecialValue.NAN)
|
|
544
|
+
return NaN;
|
|
545
|
+
if (this._special === SpecialValue.POSITIVE_INFINITY)
|
|
546
|
+
return Infinity;
|
|
547
|
+
if (this._special === SpecialValue.NEGATIVE_INFINITY)
|
|
548
|
+
return -Infinity;
|
|
549
|
+
if (this._mantissa === 0n)
|
|
550
|
+
return this._negativeZero ? -0 : 0;
|
|
551
|
+
return Number(this.toString());
|
|
552
|
+
}
|
|
553
|
+
toString() {
|
|
554
|
+
if (this._special === SpecialValue.NAN)
|
|
555
|
+
return "NaN";
|
|
556
|
+
if (this._special === SpecialValue.POSITIVE_INFINITY)
|
|
557
|
+
return "Infinity";
|
|
558
|
+
if (this._special === SpecialValue.NEGATIVE_INFINITY)
|
|
559
|
+
return "-Infinity";
|
|
560
|
+
if (this._mantissa === 0n)
|
|
561
|
+
return "0";
|
|
562
|
+
const negative = this._mantissa < 0n;
|
|
563
|
+
const absStr = bigintAbs(this._mantissa).toString();
|
|
564
|
+
const prefix = negative ? "-" : "";
|
|
565
|
+
if (this._exponent === 0) {
|
|
566
|
+
return prefix + absStr;
|
|
1871
567
|
}
|
|
1872
|
-
if (
|
|
1873
|
-
|
|
1874
|
-
y = new Ctor(1);
|
|
1875
|
-
y.e = str.length - i;
|
|
1876
|
-
y.d = convertBase(finiteToString(y), 10, base);
|
|
1877
|
-
y.e = y.d.length;
|
|
568
|
+
if (this._exponent > 0) {
|
|
569
|
+
return prefix + absStr + "0".repeat(this._exponent);
|
|
1878
570
|
}
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
str = isExp ? "0p+0" : "0";
|
|
571
|
+
const decimalPlaces = -this._exponent;
|
|
572
|
+
if (decimalPlaces < absStr.length) {
|
|
573
|
+
const intPart = absStr.slice(0, absStr.length - decimalPlaces);
|
|
574
|
+
const fracPart = absStr.slice(absStr.length - decimalPlaces);
|
|
575
|
+
return prefix + intPart + "." + fracPart;
|
|
1885
576
|
} else {
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
} else {
|
|
1889
|
-
x = new Ctor(x);
|
|
1890
|
-
x.d = xd;
|
|
1891
|
-
x.e = e;
|
|
1892
|
-
x = divide(x, y, sd, rm, 0, base);
|
|
1893
|
-
xd = x.d;
|
|
1894
|
-
e = x.e;
|
|
1895
|
-
roundUp = inexact;
|
|
1896
|
-
}
|
|
1897
|
-
i = xd[sd];
|
|
1898
|
-
k = base / 2;
|
|
1899
|
-
roundUp = roundUp || xd[sd + 1] !== void 0;
|
|
1900
|
-
roundUp = rm < 4 ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2)) : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 || rm === (x.s < 0 ? 8 : 7));
|
|
1901
|
-
xd.length = sd;
|
|
1902
|
-
if (roundUp) {
|
|
1903
|
-
for (; ++xd[--sd] > base - 1; ) {
|
|
1904
|
-
xd[sd] = 0;
|
|
1905
|
-
if (!sd) {
|
|
1906
|
-
++e;
|
|
1907
|
-
xd.unshift(1);
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
for (len = xd.length; !xd[len - 1]; --len)
|
|
1912
|
-
;
|
|
1913
|
-
for (i = 0, str = ""; i < len; i++)
|
|
1914
|
-
str += NUMERALS.charAt(xd[i]);
|
|
1915
|
-
if (isExp) {
|
|
1916
|
-
if (len > 1) {
|
|
1917
|
-
if (baseOut == 16 || baseOut == 8) {
|
|
1918
|
-
i = baseOut == 16 ? 4 : 3;
|
|
1919
|
-
for (--len; len % i; len++)
|
|
1920
|
-
str += "0";
|
|
1921
|
-
xd = convertBase(str, base, baseOut);
|
|
1922
|
-
for (len = xd.length; !xd[len - 1]; --len)
|
|
1923
|
-
;
|
|
1924
|
-
for (i = 1, str = "1."; i < len; i++)
|
|
1925
|
-
str += NUMERALS.charAt(xd[i]);
|
|
1926
|
-
} else {
|
|
1927
|
-
str = str.charAt(0) + "." + str.slice(1);
|
|
1928
|
-
}
|
|
1929
|
-
}
|
|
1930
|
-
str = str + (e < 0 ? "p" : "p+") + e;
|
|
1931
|
-
} else if (e < 0) {
|
|
1932
|
-
for (; ++e; )
|
|
1933
|
-
str = "0" + str;
|
|
1934
|
-
str = "0." + str;
|
|
1935
|
-
} else {
|
|
1936
|
-
if (++e > len)
|
|
1937
|
-
for (e -= len; e--; )
|
|
1938
|
-
str += "0";
|
|
1939
|
-
else if (e < len)
|
|
1940
|
-
str = str.slice(0, e) + "." + str.slice(e);
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
str = (baseOut == 16 ? "0x" : baseOut == 2 ? "0b" : baseOut == 8 ? "0o" : "") + str;
|
|
1944
|
-
}
|
|
1945
|
-
return x.s < 0 ? "-" + str : str;
|
|
1946
|
-
}
|
|
1947
|
-
function truncate(arr, len) {
|
|
1948
|
-
if (arr.length > len) {
|
|
1949
|
-
arr.length = len;
|
|
1950
|
-
return true;
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
function abs(x) {
|
|
1954
|
-
return new this(x).abs();
|
|
1955
|
-
}
|
|
1956
|
-
function acos(x) {
|
|
1957
|
-
return new this(x).acos();
|
|
1958
|
-
}
|
|
1959
|
-
function acosh(x) {
|
|
1960
|
-
return new this(x).acosh();
|
|
1961
|
-
}
|
|
1962
|
-
function add(x, y) {
|
|
1963
|
-
return new this(x).plus(y);
|
|
1964
|
-
}
|
|
1965
|
-
function asin(x) {
|
|
1966
|
-
return new this(x).asin();
|
|
1967
|
-
}
|
|
1968
|
-
function asinh(x) {
|
|
1969
|
-
return new this(x).asinh();
|
|
1970
|
-
}
|
|
1971
|
-
function atan(x) {
|
|
1972
|
-
return new this(x).atan();
|
|
1973
|
-
}
|
|
1974
|
-
function atanh(x) {
|
|
1975
|
-
return new this(x).atanh();
|
|
1976
|
-
}
|
|
1977
|
-
function atan2(y, x) {
|
|
1978
|
-
y = new this(y);
|
|
1979
|
-
x = new this(x);
|
|
1980
|
-
var r, pr = this.precision, rm = this.rounding, wpr = pr + 4;
|
|
1981
|
-
if (!y.s || !x.s) {
|
|
1982
|
-
r = new this(NaN);
|
|
1983
|
-
} else if (!y.d && !x.d) {
|
|
1984
|
-
r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
|
|
1985
|
-
r.s = y.s;
|
|
1986
|
-
} else if (!x.d || y.isZero()) {
|
|
1987
|
-
r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
|
|
1988
|
-
r.s = y.s;
|
|
1989
|
-
} else if (!y.d || x.isZero()) {
|
|
1990
|
-
r = getPi(this, wpr, 1).times(0.5);
|
|
1991
|
-
r.s = y.s;
|
|
1992
|
-
} else if (x.s < 0) {
|
|
1993
|
-
this.precision = wpr;
|
|
1994
|
-
this.rounding = 1;
|
|
1995
|
-
r = this.atan(divide(y, x, wpr, 1));
|
|
1996
|
-
x = getPi(this, wpr, 1);
|
|
1997
|
-
this.precision = pr;
|
|
1998
|
-
this.rounding = rm;
|
|
1999
|
-
r = y.s < 0 ? r.minus(x) : r.plus(x);
|
|
2000
|
-
} else {
|
|
2001
|
-
r = this.atan(divide(y, x, wpr, 1));
|
|
2002
|
-
}
|
|
2003
|
-
return r;
|
|
2004
|
-
}
|
|
2005
|
-
function cbrt(x) {
|
|
2006
|
-
return new this(x).cbrt();
|
|
2007
|
-
}
|
|
2008
|
-
function ceil(x) {
|
|
2009
|
-
return finalise(x = new this(x), x.e + 1, 2);
|
|
2010
|
-
}
|
|
2011
|
-
function clamp(x, min2, max2) {
|
|
2012
|
-
return new this(x).clamp(min2, max2);
|
|
2013
|
-
}
|
|
2014
|
-
function config(obj) {
|
|
2015
|
-
if (!obj || typeof obj !== "object")
|
|
2016
|
-
throw Error(decimalError + "Object expected");
|
|
2017
|
-
var i, p, v, useDefaults = obj.defaults === true, ps = [
|
|
2018
|
-
"precision",
|
|
2019
|
-
1,
|
|
2020
|
-
MAX_DIGITS,
|
|
2021
|
-
"rounding",
|
|
2022
|
-
0,
|
|
2023
|
-
8,
|
|
2024
|
-
"toExpNeg",
|
|
2025
|
-
-EXP_LIMIT,
|
|
2026
|
-
0,
|
|
2027
|
-
"toExpPos",
|
|
2028
|
-
0,
|
|
2029
|
-
EXP_LIMIT,
|
|
2030
|
-
"maxE",
|
|
2031
|
-
0,
|
|
2032
|
-
EXP_LIMIT,
|
|
2033
|
-
"minE",
|
|
2034
|
-
-EXP_LIMIT,
|
|
2035
|
-
0,
|
|
2036
|
-
"modulo",
|
|
2037
|
-
0,
|
|
2038
|
-
9
|
|
2039
|
-
];
|
|
2040
|
-
for (i = 0; i < ps.length; i += 3) {
|
|
2041
|
-
if (p = ps[i], useDefaults)
|
|
2042
|
-
this[p] = DEFAULTS[p];
|
|
2043
|
-
if ((v = obj[p]) !== void 0) {
|
|
2044
|
-
if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2])
|
|
2045
|
-
this[p] = v;
|
|
2046
|
-
else
|
|
2047
|
-
throw Error(invalidArgument + p + ": " + v);
|
|
577
|
+
const leadingZeros = decimalPlaces - absStr.length;
|
|
578
|
+
return prefix + "0." + "0".repeat(leadingZeros) + absStr;
|
|
2048
579
|
}
|
|
2049
580
|
}
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
if (
|
|
2054
|
-
|
|
2055
|
-
if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
|
|
2056
|
-
this[p] = true;
|
|
2057
|
-
} else {
|
|
2058
|
-
throw Error(cryptoUnavailable);
|
|
2059
|
-
}
|
|
2060
|
-
} else {
|
|
2061
|
-
this[p] = false;
|
|
2062
|
-
}
|
|
2063
|
-
} else {
|
|
2064
|
-
throw Error(invalidArgument + p + ": " + v);
|
|
581
|
+
// --- Static ---
|
|
582
|
+
static pow(base, exp) {
|
|
583
|
+
const n = typeof exp === "number" ? exp : exp.toNumber();
|
|
584
|
+
if (typeof base === "number" && base === 10) {
|
|
585
|
+
return _BigDecimal._create(1n, n, SpecialValue.NONE, false);
|
|
2065
586
|
}
|
|
587
|
+
const bd = base instanceof _BigDecimal ? base : new _BigDecimal(base);
|
|
588
|
+
return bd.pow(n);
|
|
589
|
+
}
|
|
590
|
+
static set(_config) {
|
|
591
|
+
}
|
|
592
|
+
// --- Internal helpers ---
|
|
593
|
+
_isSignNegative() {
|
|
594
|
+
if (this._special === SpecialValue.NEGATIVE_INFINITY)
|
|
595
|
+
return true;
|
|
596
|
+
if (this._mantissa < 0n)
|
|
597
|
+
return true;
|
|
598
|
+
if (this._mantissa === 0n)
|
|
599
|
+
return this._negativeZero;
|
|
600
|
+
return false;
|
|
2066
601
|
}
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
function cosh(x) {
|
|
2073
|
-
return new this(x).cosh();
|
|
2074
|
-
}
|
|
2075
|
-
function clone(obj) {
|
|
2076
|
-
var i, p, ps;
|
|
2077
|
-
function Decimal2(v) {
|
|
2078
|
-
var e, i2, t, x = this;
|
|
2079
|
-
if (!(x instanceof Decimal2))
|
|
2080
|
-
return new Decimal2(v);
|
|
2081
|
-
x.constructor = Decimal2;
|
|
2082
|
-
if (isDecimalInstance(v)) {
|
|
2083
|
-
x.s = v.s;
|
|
2084
|
-
if (external) {
|
|
2085
|
-
if (!v.d || v.e > Decimal2.maxE) {
|
|
2086
|
-
x.e = NaN;
|
|
2087
|
-
x.d = null;
|
|
2088
|
-
} else if (v.e < Decimal2.minE) {
|
|
2089
|
-
x.e = 0;
|
|
2090
|
-
x.d = [0];
|
|
2091
|
-
} else {
|
|
2092
|
-
x.e = v.e;
|
|
2093
|
-
x.d = v.d.slice();
|
|
2094
|
-
}
|
|
2095
|
-
} else {
|
|
2096
|
-
x.e = v.e;
|
|
2097
|
-
x.d = v.d ? v.d.slice() : v.d;
|
|
2098
|
-
}
|
|
2099
|
-
return;
|
|
602
|
+
_specialArith(other, op) {
|
|
603
|
+
const a = this._special;
|
|
604
|
+
const b = other._special;
|
|
605
|
+
if (a === SpecialValue.NAN || b === SpecialValue.NAN) {
|
|
606
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
|
|
2100
607
|
}
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
if (v < 0) {
|
|
2110
|
-
v = -v;
|
|
2111
|
-
x.s = -1;
|
|
2112
|
-
} else {
|
|
2113
|
-
x.s = 1;
|
|
2114
|
-
}
|
|
2115
|
-
if (v === ~~v && v < 1e7) {
|
|
2116
|
-
for (e = 0, i2 = v; i2 >= 10; i2 /= 10)
|
|
2117
|
-
e++;
|
|
2118
|
-
if (external) {
|
|
2119
|
-
if (e > Decimal2.maxE) {
|
|
2120
|
-
x.e = NaN;
|
|
2121
|
-
x.d = null;
|
|
2122
|
-
} else if (e < Decimal2.minE) {
|
|
2123
|
-
x.e = 0;
|
|
2124
|
-
x.d = [0];
|
|
2125
|
-
} else {
|
|
2126
|
-
x.e = e;
|
|
2127
|
-
x.d = [v];
|
|
2128
|
-
}
|
|
2129
|
-
} else {
|
|
2130
|
-
x.e = e;
|
|
2131
|
-
x.d = [v];
|
|
608
|
+
const aNeg = this._isSignNegative();
|
|
609
|
+
const bNeg = other._isSignNegative();
|
|
610
|
+
const aInf = a === SpecialValue.POSITIVE_INFINITY || a === SpecialValue.NEGATIVE_INFINITY;
|
|
611
|
+
const bInf = b === SpecialValue.POSITIVE_INFINITY || b === SpecialValue.NEGATIVE_INFINITY;
|
|
612
|
+
if (op === "times") {
|
|
613
|
+
if (aInf || bInf) {
|
|
614
|
+
if (aInf && other._mantissa === 0n && !bInf || bInf && this._mantissa === 0n && !aInf) {
|
|
615
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
|
|
2132
616
|
}
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
if (v * 0 !== 0) {
|
|
2136
|
-
if (!v)
|
|
2137
|
-
x.s = NaN;
|
|
2138
|
-
x.e = NaN;
|
|
2139
|
-
x.d = null;
|
|
2140
|
-
return;
|
|
617
|
+
const neg = aNeg !== bNeg;
|
|
618
|
+
return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false);
|
|
2141
619
|
}
|
|
2142
|
-
return parseDecimal(x, v.toString());
|
|
2143
620
|
}
|
|
2144
|
-
if (
|
|
2145
|
-
if (
|
|
2146
|
-
|
|
2147
|
-
x.s = -1;
|
|
2148
|
-
} else {
|
|
2149
|
-
if (i2 === 43)
|
|
2150
|
-
v = v.slice(1);
|
|
2151
|
-
x.s = 1;
|
|
621
|
+
if (op === "div") {
|
|
622
|
+
if (aInf && bInf) {
|
|
623
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
|
|
2152
624
|
}
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
if (v < 0) {
|
|
2157
|
-
v = -v;
|
|
2158
|
-
x.s = -1;
|
|
2159
|
-
} else {
|
|
2160
|
-
x.s = 1;
|
|
2161
|
-
}
|
|
2162
|
-
return parseDecimal(x, v.toString());
|
|
2163
|
-
}
|
|
2164
|
-
throw Error(invalidArgument + v);
|
|
2165
|
-
}
|
|
2166
|
-
Decimal2.prototype = P;
|
|
2167
|
-
Decimal2.ROUND_UP = 0;
|
|
2168
|
-
Decimal2.ROUND_DOWN = 1;
|
|
2169
|
-
Decimal2.ROUND_CEIL = 2;
|
|
2170
|
-
Decimal2.ROUND_FLOOR = 3;
|
|
2171
|
-
Decimal2.ROUND_HALF_UP = 4;
|
|
2172
|
-
Decimal2.ROUND_HALF_DOWN = 5;
|
|
2173
|
-
Decimal2.ROUND_HALF_EVEN = 6;
|
|
2174
|
-
Decimal2.ROUND_HALF_CEIL = 7;
|
|
2175
|
-
Decimal2.ROUND_HALF_FLOOR = 8;
|
|
2176
|
-
Decimal2.EUCLID = 9;
|
|
2177
|
-
Decimal2.config = Decimal2.set = config;
|
|
2178
|
-
Decimal2.clone = clone;
|
|
2179
|
-
Decimal2.isDecimal = isDecimalInstance;
|
|
2180
|
-
Decimal2.abs = abs;
|
|
2181
|
-
Decimal2.acos = acos;
|
|
2182
|
-
Decimal2.acosh = acosh;
|
|
2183
|
-
Decimal2.add = add;
|
|
2184
|
-
Decimal2.asin = asin;
|
|
2185
|
-
Decimal2.asinh = asinh;
|
|
2186
|
-
Decimal2.atan = atan;
|
|
2187
|
-
Decimal2.atanh = atanh;
|
|
2188
|
-
Decimal2.atan2 = atan2;
|
|
2189
|
-
Decimal2.cbrt = cbrt;
|
|
2190
|
-
Decimal2.ceil = ceil;
|
|
2191
|
-
Decimal2.clamp = clamp;
|
|
2192
|
-
Decimal2.cos = cos;
|
|
2193
|
-
Decimal2.cosh = cosh;
|
|
2194
|
-
Decimal2.div = div;
|
|
2195
|
-
Decimal2.exp = exp;
|
|
2196
|
-
Decimal2.floor = floor;
|
|
2197
|
-
Decimal2.hypot = hypot;
|
|
2198
|
-
Decimal2.ln = ln;
|
|
2199
|
-
Decimal2.log = log;
|
|
2200
|
-
Decimal2.log10 = log10;
|
|
2201
|
-
Decimal2.log2 = log2;
|
|
2202
|
-
Decimal2.max = max;
|
|
2203
|
-
Decimal2.min = min;
|
|
2204
|
-
Decimal2.mod = mod;
|
|
2205
|
-
Decimal2.mul = mul;
|
|
2206
|
-
Decimal2.pow = pow;
|
|
2207
|
-
Decimal2.random = random;
|
|
2208
|
-
Decimal2.round = round;
|
|
2209
|
-
Decimal2.sign = sign;
|
|
2210
|
-
Decimal2.sin = sin;
|
|
2211
|
-
Decimal2.sinh = sinh;
|
|
2212
|
-
Decimal2.sqrt = sqrt;
|
|
2213
|
-
Decimal2.sub = sub;
|
|
2214
|
-
Decimal2.sum = sum;
|
|
2215
|
-
Decimal2.tan = tan;
|
|
2216
|
-
Decimal2.tanh = tanh;
|
|
2217
|
-
Decimal2.trunc = trunc;
|
|
2218
|
-
if (obj === void 0)
|
|
2219
|
-
obj = {};
|
|
2220
|
-
if (obj) {
|
|
2221
|
-
if (obj.defaults !== true) {
|
|
2222
|
-
ps = ["precision", "rounding", "toExpNeg", "toExpPos", "maxE", "minE", "modulo", "crypto"];
|
|
2223
|
-
for (i = 0; i < ps.length; )
|
|
2224
|
-
if (!obj.hasOwnProperty(p = ps[i++]))
|
|
2225
|
-
obj[p] = this[p];
|
|
2226
|
-
}
|
|
2227
|
-
}
|
|
2228
|
-
Decimal2.config(obj);
|
|
2229
|
-
return Decimal2;
|
|
2230
|
-
}
|
|
2231
|
-
function div(x, y) {
|
|
2232
|
-
return new this(x).div(y);
|
|
2233
|
-
}
|
|
2234
|
-
function exp(x) {
|
|
2235
|
-
return new this(x).exp();
|
|
2236
|
-
}
|
|
2237
|
-
function floor(x) {
|
|
2238
|
-
return finalise(x = new this(x), x.e + 1, 3);
|
|
2239
|
-
}
|
|
2240
|
-
function hypot() {
|
|
2241
|
-
var i, n, t = new this(0);
|
|
2242
|
-
external = false;
|
|
2243
|
-
for (i = 0; i < arguments.length; ) {
|
|
2244
|
-
n = new this(arguments[i++]);
|
|
2245
|
-
if (!n.d) {
|
|
2246
|
-
if (n.s) {
|
|
2247
|
-
external = true;
|
|
2248
|
-
return new this(1 / 0);
|
|
625
|
+
if (aInf) {
|
|
626
|
+
const neg = aNeg !== bNeg;
|
|
627
|
+
return _BigDecimal._create(0n, 0, neg ? SpecialValue.NEGATIVE_INFINITY : SpecialValue.POSITIVE_INFINITY, false);
|
|
2249
628
|
}
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
}
|
|
2254
|
-
}
|
|
2255
|
-
external = true;
|
|
2256
|
-
return t.sqrt();
|
|
2257
|
-
}
|
|
2258
|
-
function isDecimalInstance(obj) {
|
|
2259
|
-
return obj instanceof Decimal || obj && obj.toStringTag === tag || false;
|
|
2260
|
-
}
|
|
2261
|
-
function ln(x) {
|
|
2262
|
-
return new this(x).ln();
|
|
2263
|
-
}
|
|
2264
|
-
function log(x, y) {
|
|
2265
|
-
return new this(x).log(y);
|
|
2266
|
-
}
|
|
2267
|
-
function log2(x) {
|
|
2268
|
-
return new this(x).log(2);
|
|
2269
|
-
}
|
|
2270
|
-
function log10(x) {
|
|
2271
|
-
return new this(x).log(10);
|
|
2272
|
-
}
|
|
2273
|
-
function max() {
|
|
2274
|
-
return maxOrMin(this, arguments, -1);
|
|
2275
|
-
}
|
|
2276
|
-
function min() {
|
|
2277
|
-
return maxOrMin(this, arguments, 1);
|
|
2278
|
-
}
|
|
2279
|
-
function mod(x, y) {
|
|
2280
|
-
return new this(x).mod(y);
|
|
2281
|
-
}
|
|
2282
|
-
function mul(x, y) {
|
|
2283
|
-
return new this(x).mul(y);
|
|
2284
|
-
}
|
|
2285
|
-
function pow(x, y) {
|
|
2286
|
-
return new this(x).pow(y);
|
|
2287
|
-
}
|
|
2288
|
-
function random(sd) {
|
|
2289
|
-
var d, e, k, n, i = 0, r = new this(1), rd = [];
|
|
2290
|
-
if (sd === void 0)
|
|
2291
|
-
sd = this.precision;
|
|
2292
|
-
else
|
|
2293
|
-
checkInt32(sd, 1, MAX_DIGITS);
|
|
2294
|
-
k = Math.ceil(sd / LOG_BASE);
|
|
2295
|
-
if (!this.crypto) {
|
|
2296
|
-
for (; i < k; )
|
|
2297
|
-
rd[i++] = Math.random() * 1e7 | 0;
|
|
2298
|
-
} else if (crypto.getRandomValues) {
|
|
2299
|
-
d = crypto.getRandomValues(new Uint32Array(k));
|
|
2300
|
-
for (; i < k; ) {
|
|
2301
|
-
n = d[i];
|
|
2302
|
-
if (n >= 429e7) {
|
|
2303
|
-
d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
|
|
2304
|
-
} else {
|
|
2305
|
-
rd[i++] = n % 1e7;
|
|
629
|
+
if (bInf) {
|
|
630
|
+
const negZero = aNeg !== bNeg;
|
|
631
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NONE, negZero);
|
|
2306
632
|
}
|
|
2307
633
|
}
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
} else {
|
|
2315
|
-
rd.push(n % 1e7);
|
|
2316
|
-
i += 4;
|
|
634
|
+
if (op === "plus") {
|
|
635
|
+
if (aInf && bInf) {
|
|
636
|
+
if (aNeg !== bNeg) {
|
|
637
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
|
|
638
|
+
}
|
|
639
|
+
return this;
|
|
2317
640
|
}
|
|
641
|
+
if (aInf)
|
|
642
|
+
return this;
|
|
643
|
+
if (bInf)
|
|
644
|
+
return other;
|
|
2318
645
|
}
|
|
2319
|
-
|
|
2320
|
-
} else {
|
|
2321
|
-
throw Error(cryptoUnavailable);
|
|
2322
|
-
}
|
|
2323
|
-
k = rd[--i];
|
|
2324
|
-
sd %= LOG_BASE;
|
|
2325
|
-
if (k && sd) {
|
|
2326
|
-
n = mathpow(10, LOG_BASE - sd);
|
|
2327
|
-
rd[i] = (k / n | 0) * n;
|
|
646
|
+
return _BigDecimal._create(0n, 0, SpecialValue.NAN, false);
|
|
2328
647
|
}
|
|
2329
|
-
|
|
2330
|
-
rd.pop();
|
|
2331
|
-
if (i < 0) {
|
|
2332
|
-
e = 0;
|
|
2333
|
-
rd = [0];
|
|
2334
|
-
} else {
|
|
2335
|
-
e = -1;
|
|
2336
|
-
for (; rd[0] === 0; e -= LOG_BASE)
|
|
2337
|
-
rd.shift();
|
|
2338
|
-
for (k = 1, n = rd[0]; n >= 10; n /= 10)
|
|
2339
|
-
k++;
|
|
2340
|
-
if (k < LOG_BASE)
|
|
2341
|
-
e -= LOG_BASE - k;
|
|
2342
|
-
}
|
|
2343
|
-
r.e = e;
|
|
2344
|
-
r.d = rd;
|
|
2345
|
-
return r;
|
|
2346
|
-
}
|
|
2347
|
-
function round(x) {
|
|
2348
|
-
return finalise(x = new this(x), x.e + 1, this.rounding);
|
|
2349
|
-
}
|
|
2350
|
-
function sign(x) {
|
|
2351
|
-
x = new this(x);
|
|
2352
|
-
return x.d ? x.d[0] ? x.s : 0 * x.s : x.s || NaN;
|
|
2353
|
-
}
|
|
2354
|
-
function sin(x) {
|
|
2355
|
-
return new this(x).sin();
|
|
2356
|
-
}
|
|
2357
|
-
function sinh(x) {
|
|
2358
|
-
return new this(x).sinh();
|
|
2359
|
-
}
|
|
2360
|
-
function sqrt(x) {
|
|
2361
|
-
return new this(x).sqrt();
|
|
2362
|
-
}
|
|
2363
|
-
function sub(x, y) {
|
|
2364
|
-
return new this(x).sub(y);
|
|
2365
|
-
}
|
|
2366
|
-
function sum() {
|
|
2367
|
-
var i = 0, args = arguments, x = new this(args[i]);
|
|
2368
|
-
external = false;
|
|
2369
|
-
for (; x.s && ++i < args.length; )
|
|
2370
|
-
x = x.plus(args[i]);
|
|
2371
|
-
external = true;
|
|
2372
|
-
return finalise(x, this.precision, this.rounding);
|
|
2373
|
-
}
|
|
2374
|
-
function tan(x) {
|
|
2375
|
-
return new this(x).tan();
|
|
2376
|
-
}
|
|
2377
|
-
function tanh(x) {
|
|
2378
|
-
return new this(x).tanh();
|
|
2379
|
-
}
|
|
2380
|
-
function trunc(x) {
|
|
2381
|
-
return finalise(x = new this(x), x.e + 1, 1);
|
|
2382
|
-
}
|
|
2383
|
-
P[Symbol.for("nodejs.util.inspect.custom")] = P.toString;
|
|
2384
|
-
P[Symbol.toStringTag] = "Decimal";
|
|
2385
|
-
var Decimal = P.constructor = clone(DEFAULTS);
|
|
2386
|
-
LN10 = new Decimal(LN10);
|
|
2387
|
-
PI = new Decimal(PI);
|
|
648
|
+
};
|
|
2388
649
|
|
|
2389
650
|
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/constants.js
|
|
2390
|
-
var TEN = new
|
|
2391
|
-
var ZERO = new
|
|
2392
|
-
var NEGATIVE_ZERO = new
|
|
651
|
+
var TEN = new BigDecimal(10);
|
|
652
|
+
var ZERO = new BigDecimal(0);
|
|
653
|
+
var NEGATIVE_ZERO = new BigDecimal(-0);
|
|
2393
654
|
|
|
2394
655
|
// node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
|
|
2395
656
|
function memoize(fn, options) {
|
|
@@ -2592,15 +853,9 @@
|
|
|
2592
853
|
|
|
2593
854
|
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/decimal-cache.js
|
|
2594
855
|
var getPowerOf10 = memoize((exponent) => {
|
|
2595
|
-
return
|
|
856
|
+
return BigDecimal.pow(10, exponent);
|
|
2596
857
|
});
|
|
2597
858
|
|
|
2598
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
|
|
2599
|
-
Decimal.set({ toExpPos: 100 });
|
|
2600
|
-
|
|
2601
|
-
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/NumberFormat/ToRawFixed.js
|
|
2602
|
-
Decimal.set({ toExpPos: 100 });
|
|
2603
|
-
|
|
2604
859
|
// node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/regex.generated.js
|
|
2605
860
|
var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDD8E\uDD8F\uDED1-\uDED8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA]/;
|
|
2606
861
|
|
|
@@ -5801,9 +4056,8 @@
|
|
|
5801
4056
|
var DEFAULT_MATCHING_THRESHOLD = 838;
|
|
5802
4057
|
var PROCESSED_DATA;
|
|
5803
4058
|
function processData() {
|
|
5804
|
-
var _a, _b;
|
|
5805
4059
|
if (!PROCESSED_DATA) {
|
|
5806
|
-
const paradigmLocales =
|
|
4060
|
+
const paradigmLocales = data.supplemental.languageMatching["written-new"][0]?.paradigmLocales?._locales.split(" ");
|
|
5807
4061
|
const matchVariables = data.supplemental.languageMatching["written-new"].slice(1, 5);
|
|
5808
4062
|
const data2 = data.supplemental.languageMatching["written-new"].slice(5);
|
|
5809
4063
|
const matches = data2.map((d) => {
|
|
@@ -5935,7 +4189,7 @@
|
|
|
5935
4189
|
try {
|
|
5936
4190
|
const canonical = Intl.getCanonicalLocales([locale]);
|
|
5937
4191
|
return canonical[0] || locale;
|
|
5938
|
-
} catch
|
|
4192
|
+
} catch {
|
|
5939
4193
|
return locale;
|
|
5940
4194
|
}
|
|
5941
4195
|
});
|
|
@@ -5972,7 +4226,7 @@
|
|
|
5972
4226
|
try {
|
|
5973
4227
|
const candidateMaximized = new Intl.Locale(candidate).maximize().toString();
|
|
5974
4228
|
distance = candidateMaximized === maximized ? 0 + i * 40 : j * 10 + i * 40;
|
|
5975
|
-
} catch
|
|
4229
|
+
} catch {
|
|
5976
4230
|
distance = j * 10 + i * 40;
|
|
5977
4231
|
}
|
|
5978
4232
|
if (!result.distances[desired]) {
|
|
@@ -5988,7 +4242,7 @@
|
|
|
5988
4242
|
}
|
|
5989
4243
|
}
|
|
5990
4244
|
}
|
|
5991
|
-
} catch
|
|
4245
|
+
} catch {
|
|
5992
4246
|
}
|
|
5993
4247
|
}
|
|
5994
4248
|
if (result.matchedSupportedLocale && lowestDistance === 0) {
|
|
@@ -6154,10 +4408,10 @@
|
|
|
6154
4408
|
key: subtag,
|
|
6155
4409
|
value: ""
|
|
6156
4410
|
};
|
|
6157
|
-
if (keywords.find((k2) => k2.key ===
|
|
4411
|
+
if (keywords.find((k2) => k2.key === keyword?.key) === void 0) {
|
|
6158
4412
|
keywords.push(keyword);
|
|
6159
4413
|
}
|
|
6160
|
-
} else if (
|
|
4414
|
+
} else if (keyword?.value === "") {
|
|
6161
4415
|
keyword.value = subtag;
|
|
6162
4416
|
} else {
|
|
6163
4417
|
invariant2(keyword !== void 0, "Expected keyword to be defined");
|
|
@@ -6173,7 +4427,6 @@
|
|
|
6173
4427
|
|
|
6174
4428
|
// node_modules/.aspect_rules_js/@formatjs+intl-localematcher@0.0.0/node_modules/@formatjs/intl-localematcher/abstract/ResolveLocale.js
|
|
6175
4429
|
function ResolveLocale(availableLocales, requestedLocales, options, relevantExtensionKeys, localeData, getDefaultLocale) {
|
|
6176
|
-
var _a;
|
|
6177
4430
|
const matcher = options.localeMatcher;
|
|
6178
4431
|
let r;
|
|
6179
4432
|
if (matcher === "lookup") {
|
|
@@ -6203,7 +4456,7 @@
|
|
|
6203
4456
|
}
|
|
6204
4457
|
let supportedKeywords = [];
|
|
6205
4458
|
for (const key of relevantExtensionKeys) {
|
|
6206
|
-
let keyLocaleData =
|
|
4459
|
+
let keyLocaleData = foundLocaleData?.[key] ?? [];
|
|
6207
4460
|
invariant2(Array.isArray(keyLocaleData), `keyLocaleData for ${key} must be an array`);
|
|
6208
4461
|
let value = keyLocaleData[0];
|
|
6209
4462
|
invariant2(value === void 0 || typeof value === "string", `value must be a string or undefined`);
|
|
@@ -7648,8 +5901,14 @@
|
|
|
7648
5901
|
const localeOverrides = SegmentationRules[r.locale];
|
|
7649
5902
|
if (granularity in localeOverrides) {
|
|
7650
5903
|
const localeSegmentationTypeValue = localeOverrides[granularity];
|
|
7651
|
-
this.mergedSegmentationTypeValue.variables =
|
|
7652
|
-
|
|
5904
|
+
this.mergedSegmentationTypeValue.variables = {
|
|
5905
|
+
...this.mergedSegmentationTypeValue.variables,
|
|
5906
|
+
...localeSegmentationTypeValue.variables
|
|
5907
|
+
};
|
|
5908
|
+
this.mergedSegmentationTypeValue.segmentRules = {
|
|
5909
|
+
...this.mergedSegmentationTypeValue.segmentRules,
|
|
5910
|
+
...localeSegmentationTypeValue.segmentRules
|
|
5911
|
+
};
|
|
7653
5912
|
this.mergedSegmentationTypeValue.suppressions = [
|
|
7654
5913
|
...this.mergedSegmentationTypeValue.suppressions,
|
|
7655
5914
|
...localeSegmentationTypeValue.suppressions
|
|
@@ -7707,12 +5966,14 @@
|
|
|
7707
5966
|
}
|
|
7708
5967
|
resolvedOptions() {
|
|
7709
5968
|
checkReceiver(this, "resolvedOptions");
|
|
7710
|
-
return
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
5969
|
+
return {
|
|
5970
|
+
...getMultiInternalSlots(
|
|
5971
|
+
__INTERNAL_SLOT_MAP__,
|
|
5972
|
+
this,
|
|
5973
|
+
"locale",
|
|
5974
|
+
"granularity"
|
|
5975
|
+
)
|
|
5976
|
+
};
|
|
7716
5977
|
}
|
|
7717
5978
|
static supportedLocalesOf(locales, options) {
|
|
7718
5979
|
return SupportedLocales(
|
|
@@ -7731,7 +5992,7 @@
|
|
|
7731
5992
|
if (WORD_CHARACTERS_UNICODE_REGEX === void 0) {
|
|
7732
5993
|
try {
|
|
7733
5994
|
WORD_CHARACTERS_UNICODE_REGEX = new RegExp("[\\p{L}\\p{N}\\p{M}]", "u");
|
|
7734
|
-
} catch
|
|
5995
|
+
} catch {
|
|
7735
5996
|
WORD_CHARACTERS_UNICODE_REGEX = null;
|
|
7736
5997
|
}
|
|
7737
5998
|
}
|
|
@@ -7880,7 +6141,7 @@
|
|
|
7880
6141
|
enumerable: false,
|
|
7881
6142
|
configurable: true
|
|
7882
6143
|
});
|
|
7883
|
-
} catch
|
|
6144
|
+
} catch {
|
|
7884
6145
|
}
|
|
7885
6146
|
|
|
7886
6147
|
// packages/intl-segmenter/should-polyfill.ts
|
|
@@ -7898,15 +6159,4 @@
|
|
|
7898
6159
|
});
|
|
7899
6160
|
}
|
|
7900
6161
|
})();
|
|
7901
|
-
/*! Bundled license information:
|
|
7902
|
-
|
|
7903
|
-
decimal.js/decimal.mjs:
|
|
7904
|
-
(*!
|
|
7905
|
-
* decimal.js v10.6.0
|
|
7906
|
-
* An arbitrary-precision Decimal type for JavaScript.
|
|
7907
|
-
* https://github.com/MikeMcl/decimal.js
|
|
7908
|
-
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
7909
|
-
* MIT Licence
|
|
7910
|
-
*)
|
|
7911
|
-
*/
|
|
7912
6162
|
//# sourceMappingURL=polyfill.iife.js.map
|