From d7837448f6c8c65bb0dff2d448dcdb58bccc4c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Sun, 26 May 2024 23:34:03 +0800 Subject: [PATCH] =?UTF-8?q?bignumber.js=20=E4=BD=BF=E7=94=A8=E5=85=AC?= =?UTF-8?q?=E5=BC=80=E7=BB=84=E4=BB=B6=E8=BF=9B=E8=A1=8C=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 4 +- wp-includes/lib/bignumber.js/bignumber.js | 573 ---- wp-includes/lib/bignumber.js/from.txt | 1 - .../lib/bignumber.js@9.1.0/bignumber.js | 2926 +++++++++++++++++ .../lib/bignumber.js@9.1.0/bignumber.min.js | 7 + wp-includes/lib/bignumber.js@9.1.0/github.txt | 2 + 6 files changed, 2937 insertions(+), 576 deletions(-) delete mode 100644 wp-includes/lib/bignumber.js/bignumber.js delete mode 100644 wp-includes/lib/bignumber.js/from.txt create mode 100644 wp-includes/lib/bignumber.js@9.1.0/bignumber.js create mode 100644 wp-includes/lib/bignumber.js@9.1.0/bignumber.min.js create mode 100644 wp-includes/lib/bignumber.js@9.1.0/github.txt diff --git a/index.html b/index.html index 9a451e9..053ac7b 100644 --- a/index.html +++ b/index.html @@ -237,8 +237,8 @@ - - + + \ No newline at end of file diff --git a/wp-includes/lib/bignumber.js/bignumber.js b/wp-includes/lib/bignumber.js/bignumber.js deleted file mode 100644 index 155153a..0000000 --- a/wp-includes/lib/bignumber.js/bignumber.js +++ /dev/null @@ -1,573 +0,0 @@ -/* bignumber.js v2.4.0 https://github.com/MikeMcl/bignumber.js/LICENCE */ -! function (e) { - "use strict"; - - function n(e) { - function a(e, n) { - var t, r, i, o, u, s, f = this; - if (!(f instanceof a)) return j && L(26, "constructor call without new", e), new a(e, n); - if (null != n && H(n, 2, 64, M, "base")) { - if (n = 0 | n, s = e + "", 10 == n) return f = new a(e instanceof a ? e : s), U(f, P + f.e + 1, B); - if ((o = "number" == typeof e) && 0 * e != 0 || !new RegExp("^-?" + (t = "[" + b.slice(0, n) + "]+") + "(?:\\." + t + ")?$", 37 > n ? "i" : "").test(s)) return g(f, s, o, n); - o ? (f.s = 0 > 1 / e ? (s = s.slice(1), -1) : 1, j && s.replace(/^0\.0*|\./, "").length > 15 && L(M, N, e), o = !1) : f.s = 45 === s.charCodeAt(0) ? (s = s.slice(1), -1) : 1, s = D(s, 10, n, f.s) - } else { - if (e instanceof a) return f.s = e.s, f.e = e.e, f.c = (e = e.c) ? e.slice() : e, void (M = 0); - if ((o = "number" == typeof e) && 0 * e == 0) { - if (f.s = 0 > 1 / e ? (e = -e, -1) : 1, e === ~~e) { - for (r = 0, i = e; i >= 10; i /= 10, r++); - return f.e = r, f.c = [e], void (M = 0) - } - s = e + "" - } else { - if (!p.test(s = e + "")) return g(f, s, o); - f.s = 45 === s.charCodeAt(0) ? (s = s.slice(1), -1) : 1 - } - } - for ((r = s.indexOf(".")) > -1 && (s = s.replace(".", "")), (i = s.search(/e/i)) > 0 ? (0 > r && (r = i), r += +s.slice(i + 1), s = s.substring(0, i)) : 0 > r && (r = s.length), i = 0; 48 === s.charCodeAt(i); i++); - for (u = s.length; 48 === s.charCodeAt(--u);); - if (s = s.slice(i, u + 1)) - if (u = s.length, o && j && u > 15 && (e > S || e !== m(e)) && L(M, N, f.s * e), r = r - i - 1, r > z) f.c = f.e = null; - else if (G > r) f.c = [f.e = 0]; - else { - if (f.e = r, f.c = [], i = (r + 1) % y, 0 > r && (i += y), u > i) { - for (i && f.c.push(+s.slice(0, i)), u -= y; u > i;) f.c.push(+s.slice(i, i += y)); - s = s.slice(i), i = y - s.length - } else i -= u; - for (; i--; s += "0"); - f.c.push(+s) - } else f.c = [f.e = 0]; - M = 0 - } - - function D(e, n, t, i) { - var o, u, f, c, h, g, p, d = e.indexOf("."), - m = P, - w = B; - for (37 > t && (e = e.toLowerCase()), d >= 0 && (f = J, J = 0, e = e.replace(".", ""), p = new a(t), h = p.pow(e.length - d), J = f, p.c = s(l(r(h.c), h.e), 10, n), p.e = p.c.length), g = s(e, t, n), u = f = g.length; 0 == g[--f]; g.pop()); - if (!g[0]) return "0"; - if (0 > d ? --u : (h.c = g, h.e = u, h.s = i, h = C(h, p, m, w, n), g = h.c, c = h.r, u = h.e), o = u + m + 1, d = g[o], f = n / 2, c = c || 0 > o || null != g[o + 1], c = 4 > w ? (null != d || c) && (0 == w || w == (h.s < 0 ? 3 : 2)) : d > f || d == f && (4 == w || c || 6 == w && 1 & g[o - 1] || w == (h.s < 0 ? 8 : 7)), 1 > o || !g[0]) e = c ? l("1", -m) : "0"; - else { - if (g.length = o, c) - for (--n; ++g[--o] > n;) g[o] = 0, o || (++u, g.unshift(1)); - for (f = g.length; !g[--f];); - for (d = 0, e = ""; f >= d; e += b.charAt(g[d++])); - e = l(e, u) - } - return e - } - - function F(e, n, t, i) { - var o, u, s, c, h; - if (t = null != t && H(t, 0, 8, i, v) ? 0 | t : B, !e.c) return e.toString(); - if (o = e.c[0], s = e.e, null == n) h = r(e.c), h = 19 == i || 24 == i && k >= s ? f(h, s) : l(h, s); - else if (e = U(new a(e), n, t), u = e.e, h = r(e.c), c = h.length, 19 == i || 24 == i && (u >= n || k >= u)) { - for (; n > c; h += "0", c++); - h = f(h, u) - } else if (n -= s, h = l(h, u), u + 1 > c) { - if (--n > 0) - for (h += "."; n--; h += "0"); - } else if (n += u - c, n > 0) - for (u + 1 == c && (h += "."); n--; h += "0"); - return e.s < 0 && o ? "-" + h : h - } - - function _(e, n) { - var t, r, i = 0; - for (u(e[0]) && (e = e[0]), t = new a(e[0]); ++i < e.length;) { - if (r = new a(e[i]), !r.s) { - t = r; - break - } - n.call(t, r) && (t = r) - } - return t - } - - function x(e, n, t, r, i) { - return (n > e || e > t || e != c(e)) && L(r, (i || "decimal places") + (n > e || e > t ? " out of range" : " not an integer"), e), !0 - } - - function I(e, n, t) { - for (var r = 1, i = n.length; !n[--i]; n.pop()); - for (i = n[0]; i >= 10; i /= 10, r++); - return (t = r + t * y - 1) > z ? e.c = e.e = null : G > t ? e.c = [e.e = 0] : (e.e = t, e.c = n), e - } - - function L(e, n, t) { - var r = new Error(["new BigNumber", "cmp", "config", "div", "divToInt", "eq", "gt", "gte", "lt", "lte", "minus", "mod", "plus", "precision", "random", "round", "shift", "times", "toDigits", "toExponential", "toFixed", "toFormat", "toFraction", "pow", "toPrecision", "toString", "BigNumber"][e] + "() " + n + ": " + t); - throw r.name = "BigNumber Error", M = 0, r - } - - function U(e, n, t, r) { - var i, o, u, s, f, l, c, a = e.c, - h = R; - if (a) { - e: { - for (i = 1, s = a[0]; s >= 10; s /= 10, i++); - if (o = n - i, 0 > o) o += y, - u = n, - f = a[l = 0], - c = f / h[i - u - 1] % 10 | 0; - else if (l = d((o + 1) / y), l >= a.length) { - if (!r) break e; - for (; a.length <= l; a.push(0)); - f = c = 0, i = 1, o %= y, u = o - y + 1 - } else { - for (f = s = a[l], i = 1; s >= 10; s /= 10, i++); - o %= y, u = o - y + i, c = 0 > u ? 0 : f / h[i - u - 1] % 10 | 0 - } - if (r = r || 0 > n || null != a[l + 1] || (0 > u ? f : f % h[i - u - 1]), r = 4 > t ? (c || r) && (0 == t || t == (e.s < 0 ? 3 : 2)) : c > 5 || 5 == c && (4 == t || r || 6 == t && (o > 0 ? u > 0 ? f / h[i - u] : 0 : a[l - 1]) % 10 & 1 || t == (e.s < 0 ? 8 : 7)), 1 > n || !a[0]) return a.length = 0, - r ? (n -= e.e + 1, a[0] = h[(y - n % y) % y], e.e = -n || 0) : a[0] = e.e = 0, - e; - if (0 == o ? (a.length = l, s = 1, l--) : (a.length = l + 1, s = h[y - o], a[l] = u > 0 ? m(f / h[i - u] % h[u]) * s : 0), r) - for (; ;) { - if (0 == l) { - for (o = 1, u = a[0]; u >= 10; u /= 10, o++); - for (u = a[0] += s, s = 1; u >= 10; u /= 10, s++); - o != s && (e.e++, a[0] == O && (a[0] = 1)); - break - } - if (a[l] += s, a[l] != O) break; - a[l--] = 0, s = 1 - } - for (o = a.length; 0 === a[--o]; a.pop()); - } - e.e > z ? e.c = e.e = null : e.e < G && (e.c = [e.e = 0]) - } - return e - } - var C, M = 0, - T = a.prototype, - q = new a(1), - P = 20, - B = 4, - k = -7, - $ = 21, - G = -1e7, - z = 1e7, - j = !0, - H = x, - V = !1, - W = 1, - J = 100, - X = { - decimalSeparator: ".", - groupSeparator: ",", - groupSize: 3, - secondaryGroupSize: 0, - fractionGroupSeparator: " ", - fractionGroupSize: 0 - }; - return a.another = n, a.ROUND_UP = 0, a.ROUND_DOWN = 1, a.ROUND_CEIL = 2, a.ROUND_FLOOR = 3, a.ROUND_HALF_UP = 4, a.ROUND_HALF_DOWN = 5, a.ROUND_HALF_EVEN = 6, a.ROUND_HALF_CEIL = 7, a.ROUND_HALF_FLOOR = 8, a.EUCLID = 9, a.config = function () { - var e, n, t = 0, - r = {}, - i = arguments, - s = i[0], - f = s && "object" == typeof s ? function () { - return s.hasOwnProperty(n) ? null != (e = s[n]) : void 0 - } : function () { - return i.length > t ? null != (e = i[t++]) : void 0 - }; - return f(n = "DECIMAL_PLACES") && H(e, 0, E, 2, n) && (P = 0 | e), r[n] = P, f(n = "ROUNDING_MODE") && H(e, 0, 8, 2, n) && (B = 0 | e), r[n] = B, f(n = "EXPONENTIAL_AT") && (u(e) ? H(e[0], -E, 0, 2, n) && H(e[1], 0, E, 2, n) && (k = 0 | e[0], $ = 0 | e[1]) : H(e, -E, E, 2, n) && (k = -($ = 0 | (0 > e ? -e : e)))), r[n] = [k, $], f(n = "RANGE") && (u(e) ? H(e[0], -E, -1, 2, n) && H(e[1], 1, E, 2, n) && (G = 0 | e[0], z = 0 | e[1]) : H(e, -E, E, 2, n) && (0 | e ? G = -(z = 0 | (0 > e ? -e : e)) : j && L(2, n + " cannot be zero", e))), r[n] = [G, z], f(n = "ERRORS") && (e === !!e || 1 === e || 0 === e ? (M = 0, H = (j = !!e) ? x : o) : j && L(2, n + w, e)), r[n] = j, f(n = "CRYPTO") && (e === !!e || 1 === e || 0 === e ? (V = !(!e || !h), e && !V && j && L(2, "crypto unavailable", h)) : j && L(2, n + w, e)), r[n] = V, f(n = "MODULO_MODE") && H(e, 0, 9, 2, n) && (W = 0 | e), r[n] = W, f(n = "POW_PRECISION") && H(e, 0, E, 2, n) && (J = 0 | e), r[n] = J, f(n = "FORMAT") && ("object" == typeof e ? X = e : j && L(2, n + " not an object", e)), r[n] = X, r - }, a.max = function () { - return _(arguments, T.lt) - }, a.min = function () { - return _(arguments, T.gt) - }, a.random = function () { - var e = 9007199254740992, - n = Math.random() * e & 2097151 ? function () { - return m(Math.random() * e) - } : function () { - return 8388608 * (1073741824 * Math.random() | 0) + (8388608 * Math.random() | 0) - }; - return function (e) { - var t, r, i, o, u, s = 0, - f = [], - l = new a(q); - if (e = null != e && H(e, 0, E, 14) ? 0 | e : P, o = d(e / y), V) - if (h && h.getRandomValues) { - for (t = h.getRandomValues(new Uint32Array(o *= 2)); o > s;) u = 131072 * t[s] + (t[s + 1] >>> 11), u >= 9e15 ? (r = h.getRandomValues(new Uint32Array(2)), t[s] = r[0], t[s + 1] = r[1]) : (f.push(u % 1e14), s += 2); - s = o / 2 - } else if (h && h.randomBytes) { - for (t = h.randomBytes(o *= 7); o > s;) u = 281474976710656 * (31 & t[s]) + 1099511627776 * t[s + 1] + 4294967296 * t[s + 2] + 16777216 * t[s + 3] + (t[s + 4] << 16) + (t[s + 5] << 8) + t[s + 6], u >= 9e15 ? h.randomBytes(7).copy(t, s) : (f.push(u % 1e14), s += 7); - s = o / 7 - } else j && L(14, "crypto unavailable", h); - if (!s) - for (; o > s;) u = n(), 9e15 > u && (f[s++] = u % 1e14); - for (o = f[--s], e %= y, o && e && (u = R[y - e], f[s] = m(o / u) * u); 0 === f[s]; f.pop(), s--); - if (0 > s) f = [i = 0]; - else { - for (i = -1; 0 === f[0]; f.shift(), i -= y); - for (s = 1, u = f[0]; u >= 10; u /= 10, s++); - y > s && (i -= y - s) - } - return l.e = i, l.c = f, l - } - }(), C = function () { - function e(e, n, t) { - var r, i, o, u, s = 0, - f = e.length, - l = n % A, - c = n / A | 0; - for (e = e.slice(); f--;) o = e[f] % A, u = e[f] / A | 0, r = c * o + u * l, i = l * o + r % A * A + s, s = (i / t | 0) + (r / A | 0) + c * u, e[f] = i % t; - return s && e.unshift(s), e - } - - function n(e, n, t, r) { - var i, o; - if (t != r) o = t > r ? 1 : -1; - else - for (i = o = 0; t > i; i++) - if (e[i] != n[i]) { - o = e[i] > n[i] ? 1 : -1; - break - } return o - } - - function r(e, n, t, r) { - for (var i = 0; t--;) e[t] -= i, i = e[t] < n[t] ? 1 : 0, e[t] = i * r + e[t] - n[t]; - for (; !e[0] && e.length > 1; e.shift()); - } - return function (i, o, u, s, f) { - var l, c, h, g, p, d, w, v, N, b, S, R, A, E, D, F, _, x = i.s == o.s ? 1 : -1, - I = i.c, - L = o.c; - if (!(I && I[0] && L && L[0])) return new a(i.s && o.s && (I ? !L || I[0] != L[0] : L) ? I && 0 == I[0] || !L ? 0 * x : x / 0 : NaN); - for (v = new a(x), N = v.c = [], c = i.e - o.e, x = u + c + 1, f || (f = O, c = t(i.e / y) - t(o.e / y), x = x / y | 0), h = 0; L[h] == (I[h] || 0); h++); - if (L[h] > (I[h] || 0) && c--, 0 > x) N.push(1), g = !0; - else { - for (E = I.length, F = L.length, h = 0, x += 2, p = m(f / (L[0] + 1)), p > 1 && (L = e(L, p, f), I = e(I, p, f), F = L.length, E = I.length), A = F, b = I.slice(0, F), S = b.length; F > S; b[S++] = 0); - _ = L.slice(), _.unshift(0), D = L[0], L[1] >= f / 2 && D++; - do { - if (p = 0, l = n(L, b, F, S), 0 > l) { - if (R = b[0], F != S && (R = R * f + (b[1] || 0)), p = m(R / D), p > 1) - for (p >= f && (p = f - 1), d = e(L, p, f), w = d.length, S = b.length; 1 == n(d, b, w, S);) p--, r(d, w > F ? _ : L, w, f), w = d.length, l = 1; - else 0 == p && (l = p = 1), d = L.slice(), w = d.length; - if (S > w && d.unshift(0), r(b, d, S, f), S = b.length, -1 == l) - for (; n(L, b, F, S) < 1;) p++, r(b, S > F ? _ : L, S, f), S = b.length - } else 0 === l && (p++, b = [0]); - N[h++] = p, b[0] ? b[S++] = I[A] || 0 : (b = [I[A]], S = 1) - } while ((A++ < E || null != b[0]) && x--); - g = null != b[0], N[0] || N.shift() - } - if (f == O) { - for (h = 1, x = N[0]; x >= 10; x /= 10, h++); - U(v, u + (v.e = h + c * y - 1) + 1, s, g) - } else v.e = c, v.r = +g; - return v - } - }(), g = function () { - var e = /^(-?)0([xbo])(?=\w[\w.]*$)/i, - n = /^([^.]+)\.$/, - t = /^\.([^.]+)$/, - r = /^-?(Infinity|NaN)$/, - i = /^\s*\+(?=[\w.])|^\s+|\s+$/g; - return function (o, u, s, f) { - var l, c = s ? u : u.replace(i, ""); - if (r.test(c)) o.s = isNaN(c) ? null : 0 > c ? -1 : 1; - else { - if (!s && (c = c.replace(e, function (e, n, t) { - return l = "x" == (t = t.toLowerCase()) ? 16 : "b" == t ? 2 : 8, f && f != l ? e : n - }), f && (l = f, c = c.replace(n, "$1").replace(t, "0.$1")), u != c)) return new a(c, l); - j && L(M, "not a" + (f ? " base " + f : "") + " number", u), o.s = null - } - o.c = o.e = null, M = 0 - } - }(), T.absoluteValue = T.abs = function () { - var e = new a(this); - return e.s < 0 && (e.s = 1), e - }, T.ceil = function () { - return U(new a(this), this.e + 1, 2) - }, T.comparedTo = T.cmp = function (e, n) { - return M = 1, i(this, new a(e, n)) - }, T.decimalPlaces = T.dp = function () { - var e, n, r = this.c; - if (!r) return null; - if (e = ((n = r.length - 1) - t(this.e / y)) * y, n = r[n]) - for (; n % 10 == 0; n /= 10, e--); - return 0 > e && (e = 0), e - }, T.dividedBy = T.div = function (e, n) { - return M = 3, C(this, new a(e, n), P, B) - }, T.dividedToIntegerBy = T.divToInt = function (e, n) { - return M = 4, C(this, new a(e, n), 0, 1) - }, T.equals = T.eq = function (e, n) { - return M = 5, 0 === i(this, new a(e, n)) - }, T.floor = function () { - return U(new a(this), this.e + 1, 3) - }, T.greaterThan = T.gt = function (e, n) { - return M = 6, i(this, new a(e, n)) > 0 - }, T.greaterThanOrEqualTo = T.gte = function (e, n) { - return M = 7, 1 === (n = i(this, new a(e, n))) || 0 === n - }, T.isFinite = function () { - return !!this.c - }, T.isInteger = T.isInt = function () { - return !!this.c && t(this.e / y) > this.c.length - 2 - }, T.isNaN = function () { - return !this.s - }, T.isNegative = T.isNeg = function () { - return this.s < 0 - }, T.isZero = function () { - return !!this.c && 0 == this.c[0] - }, T.lessThan = T.lt = function (e, n) { - return M = 8, i(this, new a(e, n)) < 0 - }, T.lessThanOrEqualTo = T.lte = function (e, n) { - return M = 9, -1 === (n = i(this, new a(e, n))) || 0 === n - }, T.minus = T.sub = function (e, n) { - var r, i, o, u, s = this, - f = s.s; - if (M = 10, e = new a(e, n), n = e.s, !f || !n) return new a(NaN); - if (f != n) return e.s = -n, s.plus(e); - var l = s.e / y, - c = e.e / y, - h = s.c, - g = e.c; - if (!l || !c) { - if (!h || !g) return h ? (e.s = -n, e) : new a(g ? s : NaN); - if (!h[0] || !g[0]) return g[0] ? (e.s = -n, e) : new a(h[0] ? s : 3 == B ? -0 : 0) - } - if (l = t(l), c = t(c), h = h.slice(), f = l - c) { - for ((u = 0 > f) ? (f = -f, o = h) : (c = l, o = g), o.reverse(), n = f; n--; o.push(0)); - o.reverse() - } else - for (i = (u = (f = h.length) < (n = g.length)) ? f : n, f = n = 0; i > n; n++) - if (h[n] != g[n]) { - u = h[n] < g[n]; - break - } if (u && (o = h, h = g, g = o, e.s = -e.s), n = (i = g.length) - (r = h.length), n > 0) - for (; n--; h[r++] = 0); - for (n = O - 1; i > f;) { - if (h[--i] < g[i]) { - for (r = i; r && !h[--r]; h[r] = n); - --h[r], h[i] += O - } - h[i] -= g[i] - } - for (; 0 == h[0]; h.shift(), --c); - return h[0] ? I(e, h, c) : (e.s = 3 == B ? -1 : 1, e.c = [e.e = 0], e) - }, T.modulo = T.mod = function (e, n) { - var t, r, i = this; - return M = 11, e = new a(e, n), !i.c || !e.s || e.c && !e.c[0] ? new a(NaN) : !e.c || i.c && !i.c[0] ? new a(i) : (9 == W ? (r = e.s, e.s = 1, t = C(i, e, 0, 3), e.s = r, t.s *= r) : t = C(i, e, 0, W), i.minus(t.times(e))) - }, T.negated = T.neg = function () { - var e = new a(this); - return e.s = -e.s || null, e - }, T.plus = T.add = function (e, n) { - var r, i = this, - o = i.s; - if (M = 12, e = new a(e, n), n = e.s, !o || !n) return new a(NaN); - if (o != n) return e.s = -n, i.minus(e); - var u = i.e / y, - s = e.e / y, - f = i.c, - l = e.c; - if (!u || !s) { - if (!f || !l) return new a(o / 0); - if (!f[0] || !l[0]) return l[0] ? e : new a(f[0] ? i : 0 * o) - } - if (u = t(u), s = t(s), f = f.slice(), o = u - s) { - for (o > 0 ? (s = u, r = l) : (o = -o, r = f), r.reverse(); o--; r.push(0)); - r.reverse() - } - for (o = f.length, n = l.length, 0 > o - n && (r = l, l = f, f = r, n = o), o = 0; n;) o = (f[--n] = f[n] + l[n] + o) / O | 0, f[n] %= O; - return o && (f.unshift(o), ++s), I(e, f, s) - }, T.precision = T.sd = function (e) { - var n, t, r = this, - i = r.c; - if (null != e && e !== !!e && 1 !== e && 0 !== e && (j && L(13, "argument" + w, e), e != !!e && (e = null)), !i) return null; - if (t = i.length - 1, n = t * y + 1, t = i[t]) { - for (; t % 10 == 0; t /= 10, n--); - for (t = i[0]; t >= 10; t /= 10, n++); - } - return e && r.e + 1 > n && (n = r.e + 1), n - }, T.round = function (e, n) { - var t = new a(this); - return (null == e || H(e, 0, E, 15)) && U(t, ~~e + this.e + 1, null != n && H(n, 0, 8, 15, v) ? 0 | n : B), t - }, T.shift = function (e) { - var n = this; - return H(e, -S, S, 16, "argument") ? n.times("1e" + c(e)) : new a(n.c && n.c[0] && (-S > e || e > S) ? n.s * (0 > e ? 0 : 1 / 0) : n) - }, T.squareRoot = T.sqrt = function () { - var e, n, i, o, u, s = this, - f = s.c, - l = s.s, - c = s.e, - h = P + 4, - g = new a("0.5"); - if (1 !== l || !f || !f[0]) return new a(!l || 0 > l && (!f || f[0]) ? NaN : f ? s : 1 / 0); - if (l = Math.sqrt(+s), 0 == l || l == 1 / 0 ? (n = r(f), (n.length + c) % 2 == 0 && (n += "0"), l = Math.sqrt(n), c = t((c + 1) / 2) - (0 > c || c % 2), l == 1 / 0 ? n = "1e" + c : (n = l.toExponential(), n = n.slice(0, n.indexOf("e") + 1) + c), i = new a(n)) : i = new a(l + ""), i.c[0]) - for (c = i.e, l = c + h, 3 > l && (l = 0); ;) - if (u = i, i = g.times(u.plus(C(s, u, h, 1))), r(u.c).slice(0, l) === (n = r(i.c)).slice(0, l)) { - if (i.e < c && --l, n = n.slice(l - 3, l + 1), "9999" != n && (o || "4999" != n)) { - (!+n || !+n.slice(1) && "5" == n.charAt(0)) && (U(i, i.e + P + 2, 1), e = !i.times(i).eq(s)); - break - } - if (!o && (U(u, u.e + P + 2, 0), u.times(u).eq(s))) { - i = u; - break - } - h += 4, l += 4, o = 1 - } return U(i, i.e + P + 1, B, e) - }, T.times = T.mul = function (e, n) { - var r, i, o, u, s, f, l, c, h, g, p, d, m, w, v, N = this, - b = N.c, - S = (M = 17, e = new a(e, n)).c; - if (!(b && S && b[0] && S[0])) return !N.s || !e.s || b && !b[0] && !S || S && !S[0] && !b ? e.c = e.e = e.s = null : (e.s *= N.s, b && S ? (e.c = [0], e.e = 0) : e.c = e.e = null), e; - for (i = t(N.e / y) + t(e.e / y), e.s *= N.s, l = b.length, g = S.length, g > l && (m = b, b = S, S = m, o = l, l = g, g = o), o = l + g, m = []; o--; m.push(0)); - for (w = O, v = A, o = g; --o >= 0;) { - for (r = 0, p = S[o] % v, d = S[o] / v | 0, s = l, u = o + s; u > o;) c = b[--s] % v, h = b[s] / v | 0, f = d * c + h * p, c = p * c + f % v * v + m[u] + r, r = (c / w | 0) + (f / v | 0) + d * h, m[u--] = c % w; - m[u] = r - } - return r ? ++i : m.shift(), I(e, m, i) - }, T.toDigits = function (e, n) { - var t = new a(this); - return e = null != e && H(e, 1, E, 18, "precision") ? 0 | e : null, n = null != n && H(n, 0, 8, 18, v) ? 0 | n : B, e ? U(t, e, n) : t - }, T.toExponential = function (e, n) { - return F(this, null != e && H(e, 0, E, 19) ? ~~e + 1 : null, n, 19) - }, T.toFixed = function (e, n) { - return F(this, null != e && H(e, 0, E, 20) ? ~~e + this.e + 1 : null, n, 20) - }, T.toFormat = function (e, n) { - var t = F(this, null != e && H(e, 0, E, 21) ? ~~e + this.e + 1 : null, n, 21); - if (this.c) { - var r, i = t.split("."), - o = +X.groupSize, - u = +X.secondaryGroupSize, - s = X.groupSeparator, - f = i[0], - l = i[1], - c = this.s < 0, - a = c ? f.slice(1) : f, - h = a.length; - if (u && (r = o, o = u, u = r, h -= r), o > 0 && h > 0) { - for (r = h % o || o, f = a.substr(0, r); h > r; r += o) f += s + a.substr(r, o); - u > 0 && (f += s + a.slice(r)), c && (f = "-" + f) - } - t = l ? f + X.decimalSeparator + ((u = +X.fractionGroupSize) ? l.replace(new RegExp("\\d{" + u + "}\\B", "g"), "$&" + X.fractionGroupSeparator) : l) : f - } - return t - }, T.toFraction = function (e) { - var n, t, i, o, u, s, f, l, c, h = j, - g = this, - p = g.c, - d = new a(q), - m = t = new a(q), - w = f = new a(q); - if (null != e && (j = !1, s = new a(e), j = h, (!(h = s.isInt()) || s.lt(q)) && (j && L(22, "max denominator " + (h ? "out of range" : "not an integer"), e), e = !h && s.c && U(s, s.e + 1, 1).gte(q) ? s : null)), !p) return g.toString(); - for (c = r(p), o = d.e = c.length - g.e - 1, d.c[0] = R[(u = o % y) < 0 ? y + u : u], e = !e || s.cmp(d) > 0 ? o > 0 ? d : m : s, u = z, z = 1 / 0, s = new a(c), f.c[0] = 0; l = C(s, d, 0, 1), i = t.plus(l.times(w)), 1 != i.cmp(e);) t = w, w = i, m = f.plus(l.times(i = m)), f = i, d = s.minus(l.times(i = d)), s = i; - return i = C(e.minus(t), w, 0, 1), f = f.plus(i.times(m)), t = t.plus(i.times(w)), f.s = m.s = g.s, o *= 2, n = C(m, w, o, B).minus(g).abs().cmp(C(f, t, o, B).minus(g).abs()) < 1 ? [m.toString(), w.toString()] : [f.toString(), t.toString()], z = u, n - }, T.toNumber = function () { - return +this - }, T.toPower = T.pow = function (e, n) { - var t, r, i, o = m(0 > e ? -e : +e), - u = this; - if (null != n && (M = 23, n = new a(n)), !H(e, -S, S, 23, "exponent") && (!isFinite(e) || o > S && (e /= 0) || parseFloat(e) != e && !(e = NaN)) || 0 == e) return t = Math.pow(+u, e), new a(n ? t % n : t); - for (n ? e > 1 && u.gt(q) && u.isInt() && n.gt(q) && n.isInt() ? u = u.mod(n) : (i = n, n = null) : J && (t = d(J / y + 2)), r = new a(q); ;) { - if (o % 2) { - if (r = r.times(u), !r.c) break; - t ? r.c.length > t && (r.c.length = t) : n && (r = r.mod(n)) - } - if (o = m(o / 2), !o) break; - u = u.times(u), t ? u.c && u.c.length > t && (u.c.length = t) : n && (u = u.mod(n)) - } - return n ? r : (0 > e && (r = q.div(r)), i ? r.mod(i) : t ? U(r, J, B) : r) - }, T.toPrecision = function (e, n) { - return F(this, null != e && H(e, 1, E, 24, "precision") ? 0 | e : null, n, 24) - }, T.toString = function (e) { - var n, t = this, - i = t.s, - o = t.e; - return null === o ? i ? (n = "Infinity", 0 > i && (n = "-" + n)) : n = "NaN" : (n = r(t.c), n = null != e && H(e, 2, 64, 25, "base") ? D(l(n, o), 0 | e, 10, i) : k >= o || o >= $ ? f(n, o) : l(n, o), 0 > i && t.c[0] && (n = "-" + n)), n - }, T.truncated = T.trunc = function () { - return U(new a(this), this.e + 1, 1) - }, T.valueOf = T.toJSON = function () { - var e, n = this, - t = n.e; - return null === t ? n.toString() : (e = r(n.c), e = k >= t || t >= $ ? f(e, t) : l(e, t), n.s < 0 ? "-" + e : e) - }, null != e && a.config(e), a - } - - function t(e) { - var n = 0 | e; - return e > 0 || e === n ? n : n - 1 - } - - function r(e) { - for (var n, t, r = 1, i = e.length, o = e[0] + ""; i > r;) { - for (n = e[r++] + "", t = y - n.length; t--; n = "0" + n); - o += n - } - for (i = o.length; 48 === o.charCodeAt(--i);); - return o.slice(0, i + 1 || 1) - } - - function i(e, n) { - var t, r, i = e.c, - o = n.c, - u = e.s, - s = n.s, - f = e.e, - l = n.e; - if (!u || !s) return null; - if (t = i && !i[0], r = o && !o[0], t || r) return t ? r ? 0 : -s : u; - if (u != s) return u; - if (t = 0 > u, r = f == l, !i || !o) return r ? 0 : !i ^ t ? 1 : -1; - if (!r) return f > l ^ t ? 1 : -1; - for (s = (f = i.length) < (l = o.length) ? f : l, u = 0; s > u; u++) - if (i[u] != o[u]) return i[u] > o[u] ^ t ? 1 : -1; - return f == l ? 0 : f > l ^ t ? 1 : -1 - } - - function o(e, n, t) { - return (e = c(e)) >= n && t >= e - } - - function u(e) { - return "[object Array]" == Object.prototype.toString.call(e) - } - - function s(e, n, t) { - for (var r, i, o = [0], u = 0, s = e.length; s > u;) { - for (i = o.length; i--; o[i] *= n); - for (o[r = 0] += b.indexOf(e.charAt(u++)); r < o.length; r++) o[r] > t - 1 && (null == o[r + 1] && (o[r + 1] = 0), o[r + 1] += o[r] / t | 0, o[r] %= t) - } - return o.reverse() - } - - function f(e, n) { - return (e.length > 1 ? e.charAt(0) + "." + e.slice(1) : e) + (0 > n ? "e" : "e+") + n - } - - function l(e, n) { - var t, r; - if (0 > n) { - for (r = "0."; ++n; r += "0"); - e = r + e - } else if (t = e.length, ++n > t) { - for (r = "0", n -= t; --n; r += "0"); - e += r - } else t > n && (e = e.slice(0, n) + "." + e.slice(n)); - return e - } - - function c(e) { - return e = parseFloat(e), 0 > e ? d(e) : m(e) - } - var a, h, g, p = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, - d = Math.ceil, - m = Math.floor, - w = " not a boolean or binary digit", - v = "rounding mode", - N = "number type has more than 15 significant digits", - b = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_", - O = 1e14, - y = 14, - S = 9007199254740991, - R = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], - A = 1e7, - E = 1e9; - if ("undefined" != typeof crypto && (h = crypto), a = n(), a["default"] = a.BigNumber = a, "function" == typeof define && define.amd) define(function () { - return a - }); - else if ("undefined" != typeof module && module.exports) { - if (module.exports = a, !h) try { - h = require("crypto") - } catch (D) { } - } else e || (e = "undefined" != typeof self ? self : Function("return this")()), e.BigNumber = a -}(this); diff --git a/wp-includes/lib/bignumber.js/from.txt b/wp-includes/lib/bignumber.js/from.txt deleted file mode 100644 index 3956590..0000000 --- a/wp-includes/lib/bignumber.js/from.txt +++ /dev/null @@ -1 +0,0 @@ -从源代码中分离出来,未找到源码 \ No newline at end of file diff --git a/wp-includes/lib/bignumber.js@9.1.0/bignumber.js b/wp-includes/lib/bignumber.js@9.1.0/bignumber.js new file mode 100644 index 0000000..1dce90e --- /dev/null +++ b/wp-includes/lib/bignumber.js@9.1.0/bignumber.js @@ -0,0 +1,2926 @@ +;(function (globalObject) { + 'use strict'; + + /* + * bignumber.js v9.1.0 + * A JavaScript library for arbitrary-precision arithmetic. + * https://github.com/MikeMcl/bignumber.js + * Copyright (c) 2022 Michael Mclaughlin + * MIT Licensed. + * + * BigNumber.prototype methods | BigNumber methods + * | + * absoluteValue abs | clone + * comparedTo | config set + * decimalPlaces dp | DECIMAL_PLACES + * dividedBy div | ROUNDING_MODE + * dividedToIntegerBy idiv | EXPONENTIAL_AT + * exponentiatedBy pow | RANGE + * integerValue | CRYPTO + * isEqualTo eq | MODULO_MODE + * isFinite | POW_PRECISION + * isGreaterThan gt | FORMAT + * isGreaterThanOrEqualTo gte | ALPHABET + * isInteger | isBigNumber + * isLessThan lt | maximum max + * isLessThanOrEqualTo lte | minimum min + * isNaN | random + * isNegative | sum + * isPositive | + * isZero | + * minus | + * modulo mod | + * multipliedBy times | + * negated | + * plus | + * precision sd | + * shiftedBy | + * squareRoot sqrt | + * toExponential | + * toFixed | + * toFormat | + * toFraction | + * toJSON | + * toNumber | + * toPrecision | + * toString | + * valueOf | + * + */ + + + var BigNumber, + isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, + mathceil = Math.ceil, + mathfloor = Math.floor, + + bignumberError = '[BigNumber Error] ', + tooManyDigits = bignumberError + 'Number primitive has more than 15 significant digits: ', + + BASE = 1e14, + LOG_BASE = 14, + MAX_SAFE_INTEGER = 0x1fffffffffffff, // 2^53 - 1 + // MAX_INT32 = 0x7fffffff, // 2^31 - 1 + POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], + SQRT_BASE = 1e7, + + // EDITABLE + // The limit on the value of DECIMAL_PLACES, TO_EXP_NEG, TO_EXP_POS, MIN_EXP, MAX_EXP, and + // the arguments to toExponential, toFixed, toFormat, and toPrecision. + MAX = 1E9; // 0 to MAX_INT32 + + + /* + * Create and return a BigNumber constructor. + */ + function clone(configObject) { + var div, convertBase, parseNumeric, + P = BigNumber.prototype = { constructor: BigNumber, toString: null, valueOf: null }, + ONE = new BigNumber(1), + + + //----------------------------- EDITABLE CONFIG DEFAULTS ------------------------------- + + + // The default values below must be integers within the inclusive ranges stated. + // The values can also be changed at run-time using BigNumber.set. + + // The maximum number of decimal places for operations involving division. + DECIMAL_PLACES = 20, // 0 to MAX + + // The rounding mode used when rounding to the above decimal places, and when using + // toExponential, toFixed, toFormat and toPrecision, and round (default value). + // UP 0 Away from zero. + // DOWN 1 Towards zero. + // CEIL 2 Towards +Infinity. + // FLOOR 3 Towards -Infinity. + // HALF_UP 4 Towards nearest neighbour. If equidistant, up. + // HALF_DOWN 5 Towards nearest neighbour. If equidistant, down. + // HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour. + // HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity. + // HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity. + ROUNDING_MODE = 4, // 0 to 8 + + // EXPONENTIAL_AT : [TO_EXP_NEG , TO_EXP_POS] + + // The exponent value at and beneath which toString returns exponential notation. + // Number type: -7 + TO_EXP_NEG = -7, // 0 to -MAX + + // The exponent value at and above which toString returns exponential notation. + // Number type: 21 + TO_EXP_POS = 21, // 0 to MAX + + // RANGE : [MIN_EXP, MAX_EXP] + + // The minimum exponent value, beneath which underflow to zero occurs. + // Number type: -324 (5e-324) + MIN_EXP = -1e7, // -1 to -MAX + + // The maximum exponent value, above which overflow to Infinity occurs. + // Number type: 308 (1.7976931348623157e+308) + // For MAX_EXP > 1e7, e.g. new BigNumber('1e100000000').plus(1) may be slow. + MAX_EXP = 1e7, // 1 to MAX + + // Whether to use cryptographically-secure random number generation, if available. + CRYPTO = false, // true or false + + // The modulo mode used when calculating the modulus: a mod n. + // The quotient (q = a / n) is calculated according to the corresponding rounding mode. + // The remainder (r) is calculated as: r = a - n * q. + // + // UP 0 The remainder is positive if the dividend is negative, else is negative. + // DOWN 1 The remainder has the same sign as the dividend. + // This modulo mode is commonly known as 'truncated division' and is + // equivalent to (a % n) in JavaScript. + // FLOOR 3 The remainder has the same sign as the divisor (Python %). + // HALF_EVEN 6 This modulo mode implements the IEEE 754 remainder function. + // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). + // The remainder is always positive. + // + // The truncated division, floored division, Euclidian division and IEEE 754 remainder + // modes are commonly used for the modulus operation. + // Although the other rounding modes can also be used, they may not give useful results. + MODULO_MODE = 1, // 0 to 9 + + // The maximum number of significant digits of the result of the exponentiatedBy operation. + // If POW_PRECISION is 0, there will be unlimited significant digits. + POW_PRECISION = 0, // 0 to MAX + + // The format specification used by the BigNumber.prototype.toFormat method. + FORMAT = { + prefix: '', + groupSize: 3, + secondaryGroupSize: 0, + groupSeparator: ',', + decimalSeparator: '.', + fractionGroupSize: 0, + fractionGroupSeparator: '\xA0', // non-breaking space + suffix: '' + }, + + // The alphabet used for base conversion. It must be at least 2 characters long, with no '+', + // '-', '.', whitespace, or repeated character. + // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_' + ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz', + alphabetHasNormalDecimalDigits = true; + + + //------------------------------------------------------------------------------------------ + + + // CONSTRUCTOR + + + /* + * The BigNumber constructor and exported function. + * Create and return a new instance of a BigNumber object. + * + * v {number|string|BigNumber} A numeric value. + * [b] {number} The base of v. Integer, 2 to ALPHABET.length inclusive. + */ + function BigNumber(v, b) { + var alphabet, c, caseChanged, e, i, isNum, len, str, + x = this; + + // Enable constructor call without `new`. + if (!(x instanceof BigNumber)) return new BigNumber(v, b); + + if (b == null) { + + if (v && v._isBigNumber === true) { + x.s = v.s; + + if (!v.c || v.e > MAX_EXP) { + x.c = x.e = null; + } else if (v.e < MIN_EXP) { + x.c = [x.e = 0]; + } else { + x.e = v.e; + x.c = v.c.slice(); + } + + return; + } + + if ((isNum = typeof v == 'number') && v * 0 == 0) { + + // Use `1 / n` to handle minus zero also. + x.s = 1 / v < 0 ? (v = -v, -1) : 1; + + // Fast path for integers, where n < 2147483648 (2**31). + if (v === ~~v) { + for (e = 0, i = v; i >= 10; i /= 10, e++); + + if (e > MAX_EXP) { + x.c = x.e = null; + } else { + x.e = e; + x.c = [v]; + } + + return; + } + + str = String(v); + } else { + + if (!isNumeric.test(str = String(v))) return parseNumeric(x, str, isNum); + + x.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1; + } + + // Decimal point? + if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); + + // Exponential form? + if ((i = str.search(/e/i)) > 0) { + + // Determine exponent. + if (e < 0) e = i; + e += +str.slice(i + 1); + str = str.substring(0, i); + } else if (e < 0) { + + // Integer. + e = str.length; + } + + } else { + + // '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' + intCheck(b, 2, ALPHABET.length, 'Base'); + + // Allow exponential notation to be used with base 10 argument, while + // also rounding to DECIMAL_PLACES as with other bases. + if (b == 10 && alphabetHasNormalDecimalDigits) { + x = new BigNumber(v); + return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE); + } + + str = String(v); + + if (isNum = typeof v == 'number') { + + // Avoid potential interpretation of Infinity and NaN as base 44+ values. + if (v * 0 != 0) return parseNumeric(x, str, isNum, b); + + x.s = 1 / v < 0 ? (str = str.slice(1), -1) : 1; + + // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' + if (BigNumber.DEBUG && str.replace(/^0\.0*|\./, '').length > 15) { + throw Error + (tooManyDigits + v); + } + } else { + x.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1; + } + + alphabet = ALPHABET.slice(0, b); + e = i = 0; + + // Check that str is a valid base b number. + // Don't use RegExp, so alphabet can contain special characters. + for (len = str.length; i < len; i++) { + if (alphabet.indexOf(c = str.charAt(i)) < 0) { + if (c == '.') { + + // If '.' is not the first character and it has not be found before. + if (i > e) { + e = len; + continue; + } + } else if (!caseChanged) { + + // Allow e.g. hexadecimal 'FF' as well as 'ff'. + if (str == str.toUpperCase() && (str = str.toLowerCase()) || + str == str.toLowerCase() && (str = str.toUpperCase())) { + caseChanged = true; + i = -1; + e = 0; + continue; + } + } + + return parseNumeric(x, String(v), isNum, b); + } + } + + // Prevent later check for length on converted number. + isNum = false; + str = convertBase(str, b, 10, x.s); + + // Decimal point? + if ((e = str.indexOf('.')) > -1) str = str.replace('.', ''); + else e = str.length; + } + + // Determine leading zeros. + for (i = 0; str.charCodeAt(i) === 48; i++); + + // Determine trailing zeros. + for (len = str.length; str.charCodeAt(--len) === 48;); + + if (str = str.slice(i, ++len)) { + len -= i; + + // '[BigNumber Error] Number primitive has more than 15 significant digits: {n}' + if (isNum && BigNumber.DEBUG && + len > 15 && (v > MAX_SAFE_INTEGER || v !== mathfloor(v))) { + throw Error + (tooManyDigits + (x.s * v)); + } + + // Overflow? + if ((e = e - i - 1) > MAX_EXP) { + + // Infinity. + x.c = x.e = null; + + // Underflow? + } else if (e < MIN_EXP) { + + // Zero. + x.c = [x.e = 0]; + } else { + x.e = e; + x.c = []; + + // Transform base + + // e is the base 10 exponent. + // i is where to slice str to get the first element of the coefficient array. + i = (e + 1) % LOG_BASE; + if (e < 0) i += LOG_BASE; // i < 1 + + if (i < len) { + if (i) x.c.push(+str.slice(0, i)); + + for (len -= LOG_BASE; i < len;) { + x.c.push(+str.slice(i, i += LOG_BASE)); + } + + i = LOG_BASE - (str = str.slice(i)).length; + } else { + i -= len; + } + + for (; i--; str += '0'); + x.c.push(+str); + } + } else { + + // Zero. + x.c = [x.e = 0]; + } + } + + + // CONSTRUCTOR PROPERTIES + + + BigNumber.clone = clone; + + BigNumber.ROUND_UP = 0; + BigNumber.ROUND_DOWN = 1; + BigNumber.ROUND_CEIL = 2; + BigNumber.ROUND_FLOOR = 3; + BigNumber.ROUND_HALF_UP = 4; + BigNumber.ROUND_HALF_DOWN = 5; + BigNumber.ROUND_HALF_EVEN = 6; + BigNumber.ROUND_HALF_CEIL = 7; + BigNumber.ROUND_HALF_FLOOR = 8; + BigNumber.EUCLID = 9; + + + /* + * Configure infrequently-changing library-wide settings. + * + * Accept an object with the following optional properties (if the value of a property is + * a number, it must be an integer within the inclusive range stated): + * + * DECIMAL_PLACES {number} 0 to MAX + * ROUNDING_MODE {number} 0 to 8 + * EXPONENTIAL_AT {number|number[]} -MAX to MAX or [-MAX to 0, 0 to MAX] + * RANGE {number|number[]} -MAX to MAX (not zero) or [-MAX to -1, 1 to MAX] + * CRYPTO {boolean} true or false + * MODULO_MODE {number} 0 to 9 + * POW_PRECISION {number} 0 to MAX + * ALPHABET {string} A string of two or more unique characters which does + * not contain '.'. + * FORMAT {object} An object with some of the following properties: + * prefix {string} + * groupSize {number} + * secondaryGroupSize {number} + * groupSeparator {string} + * decimalSeparator {string} + * fractionGroupSize {number} + * fractionGroupSeparator {string} + * suffix {string} + * + * (The values assigned to the above FORMAT object properties are not checked for validity.) + * + * E.g. + * BigNumber.config({ DECIMAL_PLACES : 20, ROUNDING_MODE : 4 }) + * + * Ignore properties/parameters set to null or undefined, except for ALPHABET. + * + * Return an object with the properties current values. + */ + BigNumber.config = BigNumber.set = function (obj) { + var p, v; + + if (obj != null) { + + if (typeof obj == 'object') { + + // DECIMAL_PLACES {number} Integer, 0 to MAX inclusive. + // '[BigNumber Error] DECIMAL_PLACES {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'DECIMAL_PLACES')) { + v = obj[p]; + intCheck(v, 0, MAX, p); + DECIMAL_PLACES = v; + } + + // ROUNDING_MODE {number} Integer, 0 to 8 inclusive. + // '[BigNumber Error] ROUNDING_MODE {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'ROUNDING_MODE')) { + v = obj[p]; + intCheck(v, 0, 8, p); + ROUNDING_MODE = v; + } + + // EXPONENTIAL_AT {number|number[]} + // Integer, -MAX to MAX inclusive or + // [integer -MAX to 0 inclusive, 0 to MAX inclusive]. + // '[BigNumber Error] EXPONENTIAL_AT {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'EXPONENTIAL_AT')) { + v = obj[p]; + if (v && v.pop) { + intCheck(v[0], -MAX, 0, p); + intCheck(v[1], 0, MAX, p); + TO_EXP_NEG = v[0]; + TO_EXP_POS = v[1]; + } else { + intCheck(v, -MAX, MAX, p); + TO_EXP_NEG = -(TO_EXP_POS = v < 0 ? -v : v); + } + } + + // RANGE {number|number[]} Non-zero integer, -MAX to MAX inclusive or + // [integer -MAX to -1 inclusive, integer 1 to MAX inclusive]. + // '[BigNumber Error] RANGE {not a primitive number|not an integer|out of range|cannot be zero}: {v}' + if (obj.hasOwnProperty(p = 'RANGE')) { + v = obj[p]; + if (v && v.pop) { + intCheck(v[0], -MAX, -1, p); + intCheck(v[1], 1, MAX, p); + MIN_EXP = v[0]; + MAX_EXP = v[1]; + } else { + intCheck(v, -MAX, MAX, p); + if (v) { + MIN_EXP = -(MAX_EXP = v < 0 ? -v : v); + } else { + throw Error + (bignumberError + p + ' cannot be zero: ' + v); + } + } + } + + // CRYPTO {boolean} true or false. + // '[BigNumber Error] CRYPTO not true or false: {v}' + // '[BigNumber Error] crypto unavailable' + if (obj.hasOwnProperty(p = 'CRYPTO')) { + v = obj[p]; + if (v === !!v) { + if (v) { + if (typeof crypto != 'undefined' && crypto && + (crypto.getRandomValues || crypto.randomBytes)) { + CRYPTO = v; + } else { + CRYPTO = !v; + throw Error + (bignumberError + 'crypto unavailable'); + } + } else { + CRYPTO = v; + } + } else { + throw Error + (bignumberError + p + ' not true or false: ' + v); + } + } + + // MODULO_MODE {number} Integer, 0 to 9 inclusive. + // '[BigNumber Error] MODULO_MODE {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'MODULO_MODE')) { + v = obj[p]; + intCheck(v, 0, 9, p); + MODULO_MODE = v; + } + + // POW_PRECISION {number} Integer, 0 to MAX inclusive. + // '[BigNumber Error] POW_PRECISION {not a primitive number|not an integer|out of range}: {v}' + if (obj.hasOwnProperty(p = 'POW_PRECISION')) { + v = obj[p]; + intCheck(v, 0, MAX, p); + POW_PRECISION = v; + } + + // FORMAT {object} + // '[BigNumber Error] FORMAT not an object: {v}' + if (obj.hasOwnProperty(p = 'FORMAT')) { + v = obj[p]; + if (typeof v == 'object') FORMAT = v; + else throw Error + (bignumberError + p + ' not an object: ' + v); + } + + // ALPHABET {string} + // '[BigNumber Error] ALPHABET invalid: {v}' + if (obj.hasOwnProperty(p = 'ALPHABET')) { + v = obj[p]; + + // Disallow if less than two characters, + // or if it contains '+', '-', '.', whitespace, or a repeated character. + if (typeof v == 'string' && !/^.?$|[+\-.\s]|(.).*\1/.test(v)) { + alphabetHasNormalDecimalDigits = v.slice(0, 10) == '0123456789'; + ALPHABET = v; + } else { + throw Error + (bignumberError + p + ' invalid: ' + v); + } + } + + } else { + + // '[BigNumber Error] Object expected: {v}' + throw Error + (bignumberError + 'Object expected: ' + obj); + } + } + + return { + DECIMAL_PLACES: DECIMAL_PLACES, + ROUNDING_MODE: ROUNDING_MODE, + EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS], + RANGE: [MIN_EXP, MAX_EXP], + CRYPTO: CRYPTO, + MODULO_MODE: MODULO_MODE, + POW_PRECISION: POW_PRECISION, + FORMAT: FORMAT, + ALPHABET: ALPHABET + }; + }; + + + /* + * Return true if v is a BigNumber instance, otherwise return false. + * + * If BigNumber.DEBUG is true, throw if a BigNumber instance is not well-formed. + * + * v {any} + * + * '[BigNumber Error] Invalid BigNumber: {v}' + */ + BigNumber.isBigNumber = function (v) { + if (!v || v._isBigNumber !== true) return false; + if (!BigNumber.DEBUG) return true; + + var i, n, + c = v.c, + e = v.e, + s = v.s; + + out: if ({}.toString.call(c) == '[object Array]') { + + if ((s === 1 || s === -1) && e >= -MAX && e <= MAX && e === mathfloor(e)) { + + // If the first element is zero, the BigNumber value must be zero. + if (c[0] === 0) { + if (e === 0 && c.length === 1) return true; + break out; + } + + // Calculate number of digits that c[0] should have, based on the exponent. + i = (e + 1) % LOG_BASE; + if (i < 1) i += LOG_BASE; + + // Calculate number of digits of c[0]. + //if (Math.ceil(Math.log(c[0] + 1) / Math.LN10) == i) { + if (String(c[0]).length == i) { + + for (i = 0; i < c.length; i++) { + n = c[i]; + if (n < 0 || n >= BASE || n !== mathfloor(n)) break out; + } + + // Last element cannot be zero, unless it is the only element. + if (n !== 0) return true; + } + } + + // Infinity/NaN + } else if (c === null && e === null && (s === null || s === 1 || s === -1)) { + return true; + } + + throw Error + (bignumberError + 'Invalid BigNumber: ' + v); + }; + + + /* + * Return a new BigNumber whose value is the maximum of the arguments. + * + * arguments {number|string|BigNumber} + */ + BigNumber.maximum = BigNumber.max = function () { + return maxOrMin(arguments, P.lt); + }; + + + /* + * Return a new BigNumber whose value is the minimum of the arguments. + * + * arguments {number|string|BigNumber} + */ + BigNumber.minimum = BigNumber.min = function () { + return maxOrMin(arguments, P.gt); + }; + + + /* + * Return a new BigNumber with a random value equal to or greater than 0 and less than 1, + * and with dp, or DECIMAL_PLACES if dp is omitted, decimal places (or less if trailing + * zeros are produced). + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp}' + * '[BigNumber Error] crypto unavailable' + */ + BigNumber.random = (function () { + var pow2_53 = 0x20000000000000; + + // Return a 53 bit integer n, where 0 <= n < 9007199254740992. + // Check if Math.random() produces more than 32 bits of randomness. + // If it does, assume at least 53 bits are produced, otherwise assume at least 30 bits. + // 0x40000000 is 2^30, 0x800000 is 2^23, 0x1fffff is 2^21 - 1. + var random53bitInt = (Math.random() * pow2_53) & 0x1fffff + ? function () { return mathfloor(Math.random() * pow2_53); } + : function () { return ((Math.random() * 0x40000000 | 0) * 0x800000) + + (Math.random() * 0x800000 | 0); }; + + return function (dp) { + var a, b, e, k, v, + i = 0, + c = [], + rand = new BigNumber(ONE); + + if (dp == null) dp = DECIMAL_PLACES; + else intCheck(dp, 0, MAX); + + k = mathceil(dp / LOG_BASE); + + if (CRYPTO) { + + // Browsers supporting crypto.getRandomValues. + if (crypto.getRandomValues) { + + a = crypto.getRandomValues(new Uint32Array(k *= 2)); + + for (; i < k;) { + + // 53 bits: + // ((Math.pow(2, 32) - 1) * Math.pow(2, 21)).toString(2) + // 11111 11111111 11111111 11111111 11100000 00000000 00000000 + // ((Math.pow(2, 32) - 1) >>> 11).toString(2) + // 11111 11111111 11111111 + // 0x20000 is 2^21. + v = a[i] * 0x20000 + (a[i + 1] >>> 11); + + // Rejection sampling: + // 0 <= v < 9007199254740992 + // Probability that v >= 9e15, is + // 7199254740992 / 9007199254740992 ~= 0.0008, i.e. 1 in 1251 + if (v >= 9e15) { + b = crypto.getRandomValues(new Uint32Array(2)); + a[i] = b[0]; + a[i + 1] = b[1]; + } else { + + // 0 <= v <= 8999999999999999 + // 0 <= (v % 1e14) <= 99999999999999 + c.push(v % 1e14); + i += 2; + } + } + i = k / 2; + + // Node.js supporting crypto.randomBytes. + } else if (crypto.randomBytes) { + + // buffer + a = crypto.randomBytes(k *= 7); + + for (; i < k;) { + + // 0x1000000000000 is 2^48, 0x10000000000 is 2^40 + // 0x100000000 is 2^32, 0x1000000 is 2^24 + // 11111 11111111 11111111 11111111 11111111 11111111 11111111 + // 0 <= v < 9007199254740992 + v = ((a[i] & 31) * 0x1000000000000) + (a[i + 1] * 0x10000000000) + + (a[i + 2] * 0x100000000) + (a[i + 3] * 0x1000000) + + (a[i + 4] << 16) + (a[i + 5] << 8) + a[i + 6]; + + if (v >= 9e15) { + crypto.randomBytes(7).copy(a, i); + } else { + + // 0 <= (v % 1e14) <= 99999999999999 + c.push(v % 1e14); + i += 7; + } + } + i = k / 7; + } else { + CRYPTO = false; + throw Error + (bignumberError + 'crypto unavailable'); + } + } + + // Use Math.random. + if (!CRYPTO) { + + for (; i < k;) { + v = random53bitInt(); + if (v < 9e15) c[i++] = v % 1e14; + } + } + + k = c[--i]; + dp %= LOG_BASE; + + // Convert trailing digits to zeros according to dp. + if (k && dp) { + v = POWS_TEN[LOG_BASE - dp]; + c[i] = mathfloor(k / v) * v; + } + + // Remove trailing elements which are zero. + for (; c[i] === 0; c.pop(), i--); + + // Zero? + if (i < 0) { + c = [e = 0]; + } else { + + // Remove leading elements which are zero and adjust exponent accordingly. + for (e = -1 ; c[0] === 0; c.splice(0, 1), e -= LOG_BASE); + + // Count the digits of the first element of c to determine leading zeros, and... + for (i = 1, v = c[0]; v >= 10; v /= 10, i++); + + // adjust the exponent accordingly. + if (i < LOG_BASE) e -= LOG_BASE - i; + } + + rand.e = e; + rand.c = c; + return rand; + }; + })(); + + + /* + * Return a BigNumber whose value is the sum of the arguments. + * + * arguments {number|string|BigNumber} + */ + BigNumber.sum = function () { + var i = 1, + args = arguments, + sum = new BigNumber(args[0]); + for (; i < args.length;) sum = sum.plus(args[i++]); + return sum; + }; + + + // PRIVATE FUNCTIONS + + + // Called by BigNumber and BigNumber.prototype.toString. + convertBase = (function () { + var decimal = '0123456789'; + + /* + * Convert string of baseIn to an array of numbers of baseOut. + * Eg. toBaseOut('255', 10, 16) returns [15, 15]. + * Eg. toBaseOut('ff', 16, 10) returns [2, 5, 5]. + */ + function toBaseOut(str, baseIn, baseOut, alphabet) { + var j, + arr = [0], + arrL, + i = 0, + len = str.length; + + for (; i < len;) { + for (arrL = arr.length; arrL--; arr[arrL] *= baseIn); + + arr[0] += alphabet.indexOf(str.charAt(i++)); + + for (j = 0; j < arr.length; j++) { + + if (arr[j] > baseOut - 1) { + if (arr[j + 1] == null) arr[j + 1] = 0; + arr[j + 1] += arr[j] / baseOut | 0; + arr[j] %= baseOut; + } + } + } + + return arr.reverse(); + } + + // Convert a numeric string of baseIn to a numeric string of baseOut. + // If the caller is toString, we are converting from base 10 to baseOut. + // If the caller is BigNumber, we are converting from baseIn to base 10. + return function (str, baseIn, baseOut, sign, callerIsToString) { + var alphabet, d, e, k, r, x, xc, y, + i = str.indexOf('.'), + dp = DECIMAL_PLACES, + rm = ROUNDING_MODE; + + // Non-integer. + if (i >= 0) { + k = POW_PRECISION; + + // Unlimited precision. + POW_PRECISION = 0; + str = str.replace('.', ''); + y = new BigNumber(baseIn); + x = y.pow(str.length - i); + POW_PRECISION = k; + + // Convert str as if an integer, then restore the fraction part by dividing the + // result by its base raised to a power. + + y.c = toBaseOut(toFixedPoint(coeffToString(x.c), x.e, '0'), + 10, baseOut, decimal); + y.e = y.c.length; + } + + // Convert the number as integer. + + xc = toBaseOut(str, baseIn, baseOut, callerIsToString + ? (alphabet = ALPHABET, decimal) + : (alphabet = decimal, ALPHABET)); + + // xc now represents str as an integer and converted to baseOut. e is the exponent. + e = k = xc.length; + + // Remove trailing zeros. + for (; xc[--k] == 0; xc.pop()); + + // Zero? + if (!xc[0]) return alphabet.charAt(0); + + // Does str represent an integer? If so, no need for the division. + if (i < 0) { + --e; + } else { + x.c = xc; + x.e = e; + + // The sign is needed for correct rounding. + x.s = sign; + x = div(x, y, dp, rm, baseOut); + xc = x.c; + r = x.r; + e = x.e; + } + + // xc now represents str converted to baseOut. + + // THe index of the rounding digit. + d = e + dp + 1; + + // The rounding digit: the digit to the right of the digit that may be rounded up. + i = xc[d]; + + // Look at the rounding digits and mode to determine whether to round up. + + k = baseOut / 2; + r = r || d < 0 || xc[d + 1] != null; + + r = rm < 4 ? (i != null || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) + : i > k || i == k &&(rm == 4 || r || rm == 6 && xc[d - 1] & 1 || + rm == (x.s < 0 ? 8 : 7)); + + // If the index of the rounding digit is not greater than zero, or xc represents + // zero, then the result of the base conversion is zero or, if rounding up, a value + // such as 0.00001. + if (d < 1 || !xc[0]) { + + // 1^-dp or 0 + str = r ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0); + } else { + + // Truncate xc to the required number of decimal places. + xc.length = d; + + // Round up? + if (r) { + + // Rounding up may mean the previous digit has to be rounded up and so on. + for (--baseOut; ++xc[--d] > baseOut;) { + xc[d] = 0; + + if (!d) { + ++e; + xc = [1].concat(xc); + } + } + } + + // Determine trailing zeros. + for (k = xc.length; !xc[--k];); + + // E.g. [4, 11, 15] becomes 4bf. + for (i = 0, str = ''; i <= k; str += alphabet.charAt(xc[i++])); + + // Add leading zeros, decimal point and trailing zeros as required. + str = toFixedPoint(str, e, alphabet.charAt(0)); + } + + // The caller will add the sign. + return str; + }; + })(); + + + // Perform division in the specified base. Called by div and convertBase. + div = (function () { + + // Assume non-zero x and k. + function multiply(x, k, base) { + var m, temp, xlo, xhi, + carry = 0, + i = x.length, + klo = k % SQRT_BASE, + khi = k / SQRT_BASE | 0; + + for (x = x.slice(); i--;) { + xlo = x[i] % SQRT_BASE; + xhi = x[i] / SQRT_BASE | 0; + m = khi * xlo + xhi * klo; + temp = klo * xlo + ((m % SQRT_BASE) * SQRT_BASE) + carry; + carry = (temp / base | 0) + (m / SQRT_BASE | 0) + khi * xhi; + x[i] = temp % base; + } + + if (carry) x = [carry].concat(x); + + return x; + } + + function compare(a, b, aL, bL) { + var i, cmp; + + if (aL != bL) { + cmp = aL > bL ? 1 : -1; + } else { + + for (i = cmp = 0; i < aL; i++) { + + if (a[i] != b[i]) { + cmp = a[i] > b[i] ? 1 : -1; + break; + } + } + } + + return cmp; + } + + function subtract(a, b, aL, base) { + var i = 0; + + // Subtract b from a. + for (; aL--;) { + a[aL] -= i; + i = a[aL] < b[aL] ? 1 : 0; + a[aL] = i * base + a[aL] - b[aL]; + } + + // Remove leading zeros. + for (; !a[0] && a.length > 1; a.splice(0, 1)); + } + + // x: dividend, y: divisor. + return function (x, y, dp, rm, base) { + var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, + yL, yz, + s = x.s == y.s ? 1 : -1, + xc = x.c, + yc = y.c; + + // Either NaN, Infinity or 0? + if (!xc || !xc[0] || !yc || !yc[0]) { + + return new BigNumber( + + // Return NaN if either NaN, or both Infinity or 0. + !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : + + // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0. + xc && xc[0] == 0 || !yc ? s * 0 : s / 0 + ); + } + + q = new BigNumber(s); + qc = q.c = []; + e = x.e - y.e; + s = dp + e + 1; + + if (!base) { + base = BASE; + e = bitFloor(x.e / LOG_BASE) - bitFloor(y.e / LOG_BASE); + s = s / LOG_BASE | 0; + } + + // Result exponent may be one less then the current value of e. + // The coefficients of the BigNumbers from convertBase may have trailing zeros. + for (i = 0; yc[i] == (xc[i] || 0); i++); + + if (yc[i] > (xc[i] || 0)) e--; + + if (s < 0) { + qc.push(1); + more = true; + } else { + xL = xc.length; + yL = yc.length; + i = 0; + s += 2; + + // Normalise xc and yc so highest order digit of yc is >= base / 2. + + n = mathfloor(base / (yc[0] + 1)); + + // Not necessary, but to handle odd bases where yc[0] == (base / 2) - 1. + // if (n > 1 || n++ == 1 && yc[0] < base / 2) { + if (n > 1) { + yc = multiply(yc, n, base); + xc = multiply(xc, n, base); + yL = yc.length; + xL = xc.length; + } + + xi = yL; + rem = xc.slice(0, yL); + remL = rem.length; + + // Add zeros to make remainder as long as divisor. + for (; remL < yL; rem[remL++] = 0); + yz = yc.slice(); + yz = [0].concat(yz); + yc0 = yc[0]; + if (yc[1] >= base / 2) yc0++; + // Not necessary, but to prevent trial digit n > base, when using base 3. + // else if (base == 3 && yc0 == 1) yc0 = 1 + 1e-15; + + do { + n = 0; + + // Compare divisor and remainder. + cmp = compare(yc, rem, yL, remL); + + // If divisor < remainder. + if (cmp < 0) { + + // Calculate trial digit, n. + + rem0 = rem[0]; + if (yL != remL) rem0 = rem0 * base + (rem[1] || 0); + + // n is how many times the divisor goes into the current remainder. + n = mathfloor(rem0 / yc0); + + // Algorithm: + // product = divisor multiplied by trial digit (n). + // Compare product and remainder. + // If product is greater than remainder: + // Subtract divisor from product, decrement trial digit. + // Subtract product from remainder. + // If product was less than remainder at the last compare: + // Compare new remainder and divisor. + // If remainder is greater than divisor: + // Subtract divisor from remainder, increment trial digit. + + if (n > 1) { + + // n may be > base only when base is 3. + if (n >= base) n = base - 1; + + // product = divisor * trial digit. + prod = multiply(yc, n, base); + prodL = prod.length; + remL = rem.length; + + // Compare product and remainder. + // If product > remainder then trial digit n too high. + // n is 1 too high about 5% of the time, and is not known to have + // ever been more than 1 too high. + while (compare(prod, rem, prodL, remL) == 1) { + n--; + + // Subtract divisor from product. + subtract(prod, yL < prodL ? yz : yc, prodL, base); + prodL = prod.length; + cmp = 1; + } + } else { + + // n is 0 or 1, cmp is -1. + // If n is 0, there is no need to compare yc and rem again below, + // so change cmp to 1 to avoid it. + // If n is 1, leave cmp as -1, so yc and rem are compared again. + if (n == 0) { + + // divisor < remainder, so n must be at least 1. + cmp = n = 1; + } + + // product = divisor + prod = yc.slice(); + prodL = prod.length; + } + + if (prodL < remL) prod = [0].concat(prod); + + // Subtract product from remainder. + subtract(rem, prod, remL, base); + remL = rem.length; + + // If product was < remainder. + if (cmp == -1) { + + // Compare divisor and new remainder. + // If divisor < new remainder, subtract divisor from remainder. + // Trial digit n too low. + // n is 1 too low about 5% of the time, and very rarely 2 too low. + while (compare(yc, rem, yL, remL) < 1) { + n++; + + // Subtract divisor from remainder. + subtract(rem, yL < remL ? yz : yc, remL, base); + remL = rem.length; + } + } + } else if (cmp === 0) { + n++; + rem = [0]; + } // else cmp === 1 and n will be 0 + + // Add the next digit, n, to the result array. + qc[i++] = n; + + // Update the remainder. + if (rem[0]) { + rem[remL++] = xc[xi] || 0; + } else { + rem = [xc[xi]]; + remL = 1; + } + } while ((xi++ < xL || rem[0] != null) && s--); + + more = rem[0] != null; + + // Leading zero? + if (!qc[0]) qc.splice(0, 1); + } + + if (base == BASE) { + + // To calculate q.e, first get the number of digits of qc[0]. + for (i = 1, s = qc[0]; s >= 10; s /= 10, i++); + + round(q, dp + (q.e = i + e * LOG_BASE - 1) + 1, rm, more); + + // Caller is convertBase. + } else { + q.e = e; + q.r = +more; + } + + return q; + }; + })(); + + + /* + * Return a string representing the value of BigNumber n in fixed-point or exponential + * notation rounded to the specified decimal places or significant digits. + * + * n: a BigNumber. + * i: the index of the last digit required (i.e. the digit that may be rounded up). + * rm: the rounding mode. + * id: 1 (toExponential) or 2 (toPrecision). + */ + function format(n, i, rm, id) { + var c0, e, ne, len, str; + + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + + if (!n.c) return n.toString(); + + c0 = n.c[0]; + ne = n.e; + + if (i == null) { + str = coeffToString(n.c); + str = id == 1 || id == 2 && (ne <= TO_EXP_NEG || ne >= TO_EXP_POS) + ? toExponential(str, ne) + : toFixedPoint(str, ne, '0'); + } else { + n = round(new BigNumber(n), i, rm); + + // n.e may have changed if the value was rounded up. + e = n.e; + + str = coeffToString(n.c); + len = str.length; + + // toPrecision returns exponential notation if the number of significant digits + // specified is less than the number of digits necessary to represent the integer + // part of the value in fixed-point notation. + + // Exponential notation. + if (id == 1 || id == 2 && (i <= e || e <= TO_EXP_NEG)) { + + // Append zeros? + for (; len < i; str += '0', len++); + str = toExponential(str, e); + + // Fixed-point notation. + } else { + i -= ne; + str = toFixedPoint(str, e, '0'); + + // Append zeros? + if (e + 1 > len) { + if (--i > 0) for (str += '.'; i--; str += '0'); + } else { + i += e - len; + if (i > 0) { + if (e + 1 == len) str += '.'; + for (; i--; str += '0'); + } + } + } + } + + return n.s < 0 && c0 ? '-' + str : str; + } + + + // Handle BigNumber.max and BigNumber.min. + function maxOrMin(args, method) { + var n, + i = 1, + m = new BigNumber(args[0]); + + for (; i < args.length; i++) { + n = new BigNumber(args[i]); + + // If any number is NaN, return NaN. + if (!n.s) { + m = n; + break; + } else if (method.call(m, n)) { + m = n; + } + } + + return m; + } + + + /* + * Strip trailing zeros, calculate base 10 exponent and check against MIN_EXP and MAX_EXP. + * Called by minus, plus and times. + */ + function normalise(n, c, e) { + var i = 1, + j = c.length; + + // Remove trailing zeros. + for (; !c[--j]; c.pop()); + + // Calculate the base 10 exponent. First get the number of digits of c[0]. + for (j = c[0]; j >= 10; j /= 10, i++); + + // Overflow? + if ((e = i + e * LOG_BASE - 1) > MAX_EXP) { + + // Infinity. + n.c = n.e = null; + + // Underflow? + } else if (e < MIN_EXP) { + + // Zero. + n.c = [n.e = 0]; + } else { + n.e = e; + n.c = c; + } + + return n; + } + + + // Handle values that fail the validity test in BigNumber. + parseNumeric = (function () { + var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, + dotAfter = /^([^.]+)\.$/, + dotBefore = /^\.([^.]+)$/, + isInfinityOrNaN = /^-?(Infinity|NaN)$/, + whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g; + + return function (x, str, isNum, b) { + var base, + s = isNum ? str : str.replace(whitespaceOrPlus, ''); + + // No exception on ±Infinity or NaN. + if (isInfinityOrNaN.test(s)) { + x.s = isNaN(s) ? null : s < 0 ? -1 : 1; + } else { + if (!isNum) { + + // basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i + s = s.replace(basePrefix, function (m, p1, p2) { + base = (p2 = p2.toLowerCase()) == 'x' ? 16 : p2 == 'b' ? 2 : 8; + return !b || b == base ? p1 : m; + }); + + if (b) { + base = b; + + // E.g. '1.' to '1', '.1' to '0.1' + s = s.replace(dotAfter, '$1').replace(dotBefore, '0.$1'); + } + + if (str != s) return new BigNumber(s, base); + } + + // '[BigNumber Error] Not a number: {n}' + // '[BigNumber Error] Not a base {b} number: {n}' + if (BigNumber.DEBUG) { + throw Error + (bignumberError + 'Not a' + (b ? ' base ' + b : '') + ' number: ' + str); + } + + // NaN + x.s = null; + } + + x.c = x.e = null; + } + })(); + + + /* + * Round x to sd significant digits using rounding mode rm. Check for over/under-flow. + * If r is truthy, it is known that there are more digits after the rounding digit. + */ + function round(x, sd, rm, r) { + var d, i, j, k, n, ni, rd, + xc = x.c, + pows10 = POWS_TEN; + + // if x is not Infinity or NaN... + if (xc) { + + // rd is the rounding digit, i.e. the digit after the digit that may be rounded up. + // n is a base 1e14 number, the value of the element of array x.c containing rd. + // ni is the index of n within x.c. + // d is the number of digits of n. + // i is the index of rd within n including leading zeros. + // j is the actual index of rd within n (if < 0, rd is a leading zero). + out: { + + // Get the number of digits of the first element of xc. + for (d = 1, k = xc[0]; k >= 10; k /= 10, d++); + i = sd - d; + + // If the rounding digit is in the first element of xc... + if (i < 0) { + i += LOG_BASE; + j = sd; + n = xc[ni = 0]; + + // Get the rounding digit at index j of n. + rd = n / pows10[d - j - 1] % 10 | 0; + } else { + ni = mathceil((i + 1) / LOG_BASE); + + if (ni >= xc.length) { + + if (r) { + + // Needed by sqrt. + for (; xc.length <= ni; xc.push(0)); + n = rd = 0; + d = 1; + i %= LOG_BASE; + j = i - LOG_BASE + 1; + } else { + break out; + } + } else { + n = k = xc[ni]; + + // Get the number of digits of n. + for (d = 1; k >= 10; k /= 10, d++); + + // Get the index of rd within n. + i %= LOG_BASE; + + // Get the index of rd within n, adjusted for leading zeros. + // The number of leading zeros of n is given by LOG_BASE - d. + j = i - LOG_BASE + d; + + // Get the rounding digit at index j of n. + rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0; + } + } + + r = r || sd < 0 || + + // Are there any non-zero digits after the rounding digit? + // The expression n % pows10[d - j - 1] returns all digits of n to the right + // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714. + xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]); + + r = rm < 4 + ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) + : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && + + // Check whether the digit to the left of the rounding digit is odd. + ((i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10) & 1 || + rm == (x.s < 0 ? 8 : 7)); + + if (sd < 1 || !xc[0]) { + xc.length = 0; + + if (r) { + + // Convert sd to decimal places. + sd -= x.e + 1; + + // 1, 0.1, 0.01, 0.001, 0.0001 etc. + xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE]; + x.e = -sd || 0; + } else { + + // Zero. + xc[0] = x.e = 0; + } + + return x; + } + + // Remove excess digits. + if (i == 0) { + xc.length = ni; + k = 1; + ni--; + } else { + xc.length = ni + 1; + k = pows10[LOG_BASE - i]; + + // E.g. 56700 becomes 56000 if 7 is the rounding digit. + // j > 0 means i > number of leading zeros of n. + xc[ni] = j > 0 ? mathfloor(n / pows10[d - j] % pows10[j]) * k : 0; + } + + // Round up? + if (r) { + + for (; ;) { + + // If the digit to be rounded up is in the first element of xc... + if (ni == 0) { + + // i will be the length of xc[0] before k is added. + for (i = 1, j = xc[0]; j >= 10; j /= 10, i++); + j = xc[0] += k; + for (k = 1; j >= 10; j /= 10, k++); + + // if i != k the length has increased. + if (i != k) { + x.e++; + if (xc[0] == BASE) xc[0] = 1; + } + + break; + } else { + xc[ni] += k; + if (xc[ni] != BASE) break; + xc[ni--] = 0; + k = 1; + } + } + } + + // Remove trailing zeros. + for (i = xc.length; xc[--i] === 0; xc.pop()); + } + + // Overflow? Infinity. + if (x.e > MAX_EXP) { + x.c = x.e = null; + + // Underflow? Zero. + } else if (x.e < MIN_EXP) { + x.c = [x.e = 0]; + } + } + + return x; + } + + + function valueOf(n) { + var str, + e = n.e; + + if (e === null) return n.toString(); + + str = coeffToString(n.c); + + str = e <= TO_EXP_NEG || e >= TO_EXP_POS + ? toExponential(str, e) + : toFixedPoint(str, e, '0'); + + return n.s < 0 ? '-' + str : str; + } + + + // PROTOTYPE/INSTANCE METHODS + + + /* + * Return a new BigNumber whose value is the absolute value of this BigNumber. + */ + P.absoluteValue = P.abs = function () { + var x = new BigNumber(this); + if (x.s < 0) x.s = 1; + return x; + }; + + + /* + * Return + * 1 if the value of this BigNumber is greater than the value of BigNumber(y, b), + * -1 if the value of this BigNumber is less than the value of BigNumber(y, b), + * 0 if they have the same value, + * or null if the value of either is NaN. + */ + P.comparedTo = function (y, b) { + return compare(this, new BigNumber(y, b)); + }; + + + /* + * If dp is undefined or null or true or false, return the number of decimal places of the + * value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. + * + * Otherwise, if dp is a number, return a new BigNumber whose value is the value of this + * BigNumber rounded to a maximum of dp decimal places using rounding mode rm, or + * ROUNDING_MODE if rm is omitted. + * + * [dp] {number} Decimal places: integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.decimalPlaces = P.dp = function (dp, rm) { + var c, n, v, + x = this; + + if (dp != null) { + intCheck(dp, 0, MAX); + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + + return round(new BigNumber(x), dp + x.e + 1, rm); + } + + if (!(c = x.c)) return null; + n = ((v = c.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE; + + // Subtract the number of trailing zeros of the last number. + if (v = c[v]) for (; v % 10 == 0; v /= 10, n--); + if (n < 0) n = 0; + + return n; + }; + + + /* + * n / 0 = I + * n / N = N + * n / I = 0 + * 0 / n = 0 + * 0 / 0 = N + * 0 / N = N + * 0 / I = 0 + * N / n = N + * N / 0 = N + * N / N = N + * N / I = N + * I / n = I + * I / 0 = I + * I / N = N + * I / I = N + * + * Return a new BigNumber whose value is the value of this BigNumber divided by the value of + * BigNumber(y, b), rounded according to DECIMAL_PLACES and ROUNDING_MODE. + */ + P.dividedBy = P.div = function (y, b) { + return div(this, new BigNumber(y, b), DECIMAL_PLACES, ROUNDING_MODE); + }; + + + /* + * Return a new BigNumber whose value is the integer part of dividing the value of this + * BigNumber by the value of BigNumber(y, b). + */ + P.dividedToIntegerBy = P.idiv = function (y, b) { + return div(this, new BigNumber(y, b), 0, 1); + }; + + + /* + * Return a BigNumber whose value is the value of this BigNumber exponentiated by n. + * + * If m is present, return the result modulo m. + * If n is negative round according to DECIMAL_PLACES and ROUNDING_MODE. + * If POW_PRECISION is non-zero and m is not present, round to POW_PRECISION using ROUNDING_MODE. + * + * The modular power operation works efficiently when x, n, and m are integers, otherwise it + * is equivalent to calculating x.exponentiatedBy(n).modulo(m) with a POW_PRECISION of 0. + * + * n {number|string|BigNumber} The exponent. An integer. + * [m] {number|string|BigNumber} The modulus. + * + * '[BigNumber Error] Exponent not an integer: {n}' + */ + P.exponentiatedBy = P.pow = function (n, m) { + var half, isModExp, i, k, more, nIsBig, nIsNeg, nIsOdd, y, + x = this; + + n = new BigNumber(n); + + // Allow NaN and ±Infinity, but not other non-integers. + if (n.c && !n.isInteger()) { + throw Error + (bignumberError + 'Exponent not an integer: ' + valueOf(n)); + } + + if (m != null) m = new BigNumber(m); + + // Exponent of MAX_SAFE_INTEGER is 15. + nIsBig = n.e > 14; + + // If x is NaN, ±Infinity, ±0 or ±1, or n is ±Infinity, NaN or ±0. + if (!x.c || !x.c[0] || x.c[0] == 1 && !x.e && x.c.length == 1 || !n.c || !n.c[0]) { + + // The sign of the result of pow when x is negative depends on the evenness of n. + // If +n overflows to ±Infinity, the evenness of n would be not be known. + y = new BigNumber(Math.pow(+valueOf(x), nIsBig ? 2 - isOdd(n) : +valueOf(n))); + return m ? y.mod(m) : y; + } + + nIsNeg = n.s < 0; + + if (m) { + + // x % m returns NaN if abs(m) is zero, or m is NaN. + if (m.c ? !m.c[0] : !m.s) return new BigNumber(NaN); + + isModExp = !nIsNeg && x.isInteger() && m.isInteger(); + + if (isModExp) x = x.mod(m); + + // Overflow to ±Infinity: >=2**1e10 or >=1.0000024**1e15. + // Underflow to ±0: <=0.79**1e10 or <=0.9999975**1e15. + } else if (n.e > 9 && (x.e > 0 || x.e < -1 || (x.e == 0 + // [1, 240000000] + ? x.c[0] > 1 || nIsBig && x.c[1] >= 24e7 + // [80000000000000] [99999750000000] + : x.c[0] < 8e13 || nIsBig && x.c[0] <= 9999975e7))) { + + // If x is negative and n is odd, k = -0, else k = 0. + k = x.s < 0 && isOdd(n) ? -0 : 0; + + // If x >= 1, k = ±Infinity. + if (x.e > -1) k = 1 / k; + + // If n is negative return ±0, else return ±Infinity. + return new BigNumber(nIsNeg ? 1 / k : k); + + } else if (POW_PRECISION) { + + // Truncating each coefficient array to a length of k after each multiplication + // equates to truncating significant digits to POW_PRECISION + [28, 41], + // i.e. there will be a minimum of 28 guard digits retained. + k = mathceil(POW_PRECISION / LOG_BASE + 2); + } + + if (nIsBig) { + half = new BigNumber(0.5); + if (nIsNeg) n.s = 1; + nIsOdd = isOdd(n); + } else { + i = Math.abs(+valueOf(n)); + nIsOdd = i % 2; + } + + y = new BigNumber(ONE); + + // Performs 54 loop iterations for n of 9007199254740991. + for (; ;) { + + if (nIsOdd) { + y = y.times(x); + if (!y.c) break; + + if (k) { + if (y.c.length > k) y.c.length = k; + } else if (isModExp) { + y = y.mod(m); //y = y.minus(div(y, m, 0, MODULO_MODE).times(m)); + } + } + + if (i) { + i = mathfloor(i / 2); + if (i === 0) break; + nIsOdd = i % 2; + } else { + n = n.times(half); + round(n, n.e + 1, 1); + + if (n.e > 14) { + nIsOdd = isOdd(n); + } else { + i = +valueOf(n); + if (i === 0) break; + nIsOdd = i % 2; + } + } + + x = x.times(x); + + if (k) { + if (x.c && x.c.length > k) x.c.length = k; + } else if (isModExp) { + x = x.mod(m); //x = x.minus(div(x, m, 0, MODULO_MODE).times(m)); + } + } + + if (isModExp) return y; + if (nIsNeg) y = ONE.div(y); + + return m ? y.mod(m) : k ? round(y, POW_PRECISION, ROUNDING_MODE, more) : y; + }; + + + /* + * Return a new BigNumber whose value is the value of this BigNumber rounded to an integer + * using rounding mode rm, or ROUNDING_MODE if rm is omitted. + * + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {rm}' + */ + P.integerValue = function (rm) { + var n = new BigNumber(this); + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + return round(n, n.e + 1, rm); + }; + + + /* + * Return true if the value of this BigNumber is equal to the value of BigNumber(y, b), + * otherwise return false. + */ + P.isEqualTo = P.eq = function (y, b) { + return compare(this, new BigNumber(y, b)) === 0; + }; + + + /* + * Return true if the value of this BigNumber is a finite number, otherwise return false. + */ + P.isFinite = function () { + return !!this.c; + }; + + + /* + * Return true if the value of this BigNumber is greater than the value of BigNumber(y, b), + * otherwise return false. + */ + P.isGreaterThan = P.gt = function (y, b) { + return compare(this, new BigNumber(y, b)) > 0; + }; + + + /* + * Return true if the value of this BigNumber is greater than or equal to the value of + * BigNumber(y, b), otherwise return false. + */ + P.isGreaterThanOrEqualTo = P.gte = function (y, b) { + return (b = compare(this, new BigNumber(y, b))) === 1 || b === 0; + + }; + + + /* + * Return true if the value of this BigNumber is an integer, otherwise return false. + */ + P.isInteger = function () { + return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2; + }; + + + /* + * Return true if the value of this BigNumber is less than the value of BigNumber(y, b), + * otherwise return false. + */ + P.isLessThan = P.lt = function (y, b) { + return compare(this, new BigNumber(y, b)) < 0; + }; + + + /* + * Return true if the value of this BigNumber is less than or equal to the value of + * BigNumber(y, b), otherwise return false. + */ + P.isLessThanOrEqualTo = P.lte = function (y, b) { + return (b = compare(this, new BigNumber(y, b))) === -1 || b === 0; + }; + + + /* + * Return true if the value of this BigNumber is NaN, otherwise return false. + */ + P.isNaN = function () { + return !this.s; + }; + + + /* + * Return true if the value of this BigNumber is negative, otherwise return false. + */ + P.isNegative = function () { + return this.s < 0; + }; + + + /* + * Return true if the value of this BigNumber is positive, otherwise return false. + */ + P.isPositive = function () { + return this.s > 0; + }; + + + /* + * Return true if the value of this BigNumber is 0 or -0, otherwise return false. + */ + P.isZero = function () { + return !!this.c && this.c[0] == 0; + }; + + + /* + * n - 0 = n + * n - N = N + * n - I = -I + * 0 - n = -n + * 0 - 0 = 0 + * 0 - N = N + * 0 - I = -I + * N - n = N + * N - 0 = N + * N - N = N + * N - I = N + * I - n = I + * I - 0 = I + * I - N = N + * I - I = N + * + * Return a new BigNumber whose value is the value of this BigNumber minus the value of + * BigNumber(y, b). + */ + P.minus = function (y, b) { + var i, j, t, xLTy, + x = this, + a = x.s; + + y = new BigNumber(y, b); + b = y.s; + + // Either NaN? + if (!a || !b) return new BigNumber(NaN); + + // Signs differ? + if (a != b) { + y.s = -b; + return x.plus(y); + } + + var xe = x.e / LOG_BASE, + ye = y.e / LOG_BASE, + xc = x.c, + yc = y.c; + + if (!xe || !ye) { + + // Either Infinity? + if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber(yc ? x : NaN); + + // Either zero? + if (!xc[0] || !yc[0]) { + + // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. + return yc[0] ? (y.s = -b, y) : new BigNumber(xc[0] ? x : + + // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity + ROUNDING_MODE == 3 ? -0 : 0); + } + } + + xe = bitFloor(xe); + ye = bitFloor(ye); + xc = xc.slice(); + + // Determine which is the bigger number. + if (a = xe - ye) { + + if (xLTy = a < 0) { + a = -a; + t = xc; + } else { + ye = xe; + t = yc; + } + + t.reverse(); + + // Prepend zeros to equalise exponents. + for (b = a; b--; t.push(0)); + t.reverse(); + } else { + + // Exponents equal. Check digit by digit. + j = (xLTy = (a = xc.length) < (b = yc.length)) ? a : b; + + for (a = b = 0; b < j; b++) { + + if (xc[b] != yc[b]) { + xLTy = xc[b] < yc[b]; + break; + } + } + } + + // x < y? Point xc to the array of the bigger number. + if (xLTy) { + t = xc; + xc = yc; + yc = t; + y.s = -y.s; + } + + b = (j = yc.length) - (i = xc.length); + + // Append zeros to xc if shorter. + // No need to add zeros to yc if shorter as subtract only needs to start at yc.length. + if (b > 0) for (; b--; xc[i++] = 0); + b = BASE - 1; + + // Subtract yc from xc. + for (; j > a;) { + + if (xc[--j] < yc[j]) { + for (i = j; i && !xc[--i]; xc[i] = b); + --xc[i]; + xc[j] += BASE; + } + + xc[j] -= yc[j]; + } + + // Remove leading zeros and adjust exponent accordingly. + for (; xc[0] == 0; xc.splice(0, 1), --ye); + + // Zero? + if (!xc[0]) { + + // Following IEEE 754 (2008) 6.3, + // n - n = +0 but n - n = -0 when rounding towards -Infinity. + y.s = ROUNDING_MODE == 3 ? -1 : 1; + y.c = [y.e = 0]; + return y; + } + + // No need to check for Infinity as +x - +y != Infinity && -x - -y != Infinity + // for finite x and y. + return normalise(y, xc, ye); + }; + + + /* + * n % 0 = N + * n % N = N + * n % I = n + * 0 % n = 0 + * -0 % n = -0 + * 0 % 0 = N + * 0 % N = N + * 0 % I = 0 + * N % n = N + * N % 0 = N + * N % N = N + * N % I = N + * I % n = N + * I % 0 = N + * I % N = N + * I % I = N + * + * Return a new BigNumber whose value is the value of this BigNumber modulo the value of + * BigNumber(y, b). The result depends on the value of MODULO_MODE. + */ + P.modulo = P.mod = function (y, b) { + var q, s, + x = this; + + y = new BigNumber(y, b); + + // Return NaN if x is Infinity or NaN, or y is NaN or zero. + if (!x.c || !y.s || y.c && !y.c[0]) { + return new BigNumber(NaN); + + // Return x if y is Infinity or x is zero. + } else if (!y.c || x.c && !x.c[0]) { + return new BigNumber(x); + } + + if (MODULO_MODE == 9) { + + // Euclidian division: q = sign(y) * floor(x / abs(y)) + // r = x - qy where 0 <= r < abs(y) + s = y.s; + y.s = 1; + q = div(x, y, 0, 3); + y.s = s; + q.s *= s; + } else { + q = div(x, y, 0, MODULO_MODE); + } + + y = x.minus(q.times(y)); + + // To match JavaScript %, ensure sign of zero is sign of dividend. + if (!y.c[0] && MODULO_MODE == 1) y.s = x.s; + + return y; + }; + + + /* + * n * 0 = 0 + * n * N = N + * n * I = I + * 0 * n = 0 + * 0 * 0 = 0 + * 0 * N = N + * 0 * I = N + * N * n = N + * N * 0 = N + * N * N = N + * N * I = N + * I * n = I + * I * 0 = N + * I * N = N + * I * I = I + * + * Return a new BigNumber whose value is the value of this BigNumber multiplied by the value + * of BigNumber(y, b). + */ + P.multipliedBy = P.times = function (y, b) { + var c, e, i, j, k, m, xcL, xlo, xhi, ycL, ylo, yhi, zc, + base, sqrtBase, + x = this, + xc = x.c, + yc = (y = new BigNumber(y, b)).c; + + // Either NaN, ±Infinity or ±0? + if (!xc || !yc || !xc[0] || !yc[0]) { + + // Return NaN if either is NaN, or one is 0 and the other is Infinity. + if (!x.s || !y.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) { + y.c = y.e = y.s = null; + } else { + y.s *= x.s; + + // Return ±Infinity if either is ±Infinity. + if (!xc || !yc) { + y.c = y.e = null; + + // Return ±0 if either is ±0. + } else { + y.c = [0]; + y.e = 0; + } + } + + return y; + } + + e = bitFloor(x.e / LOG_BASE) + bitFloor(y.e / LOG_BASE); + y.s *= x.s; + xcL = xc.length; + ycL = yc.length; + + // Ensure xc points to longer array and xcL to its length. + if (xcL < ycL) { + zc = xc; + xc = yc; + yc = zc; + i = xcL; + xcL = ycL; + ycL = i; + } + + // Initialise the result array with zeros. + for (i = xcL + ycL, zc = []; i--; zc.push(0)); + + base = BASE; + sqrtBase = SQRT_BASE; + + for (i = ycL; --i >= 0;) { + c = 0; + ylo = yc[i] % sqrtBase; + yhi = yc[i] / sqrtBase | 0; + + for (k = xcL, j = i + k; j > i;) { + xlo = xc[--k] % sqrtBase; + xhi = xc[k] / sqrtBase | 0; + m = yhi * xlo + xhi * ylo; + xlo = ylo * xlo + ((m % sqrtBase) * sqrtBase) + zc[j] + c; + c = (xlo / base | 0) + (m / sqrtBase | 0) + yhi * xhi; + zc[j--] = xlo % base; + } + + zc[j] = c; + } + + if (c) { + ++e; + } else { + zc.splice(0, 1); + } + + return normalise(y, zc, e); + }; + + + /* + * Return a new BigNumber whose value is the value of this BigNumber negated, + * i.e. multiplied by -1. + */ + P.negated = function () { + var x = new BigNumber(this); + x.s = -x.s || null; + return x; + }; + + + /* + * n + 0 = n + * n + N = N + * n + I = I + * 0 + n = n + * 0 + 0 = 0 + * 0 + N = N + * 0 + I = I + * N + n = N + * N + 0 = N + * N + N = N + * N + I = N + * I + n = I + * I + 0 = I + * I + N = N + * I + I = I + * + * Return a new BigNumber whose value is the value of this BigNumber plus the value of + * BigNumber(y, b). + */ + P.plus = function (y, b) { + var t, + x = this, + a = x.s; + + y = new BigNumber(y, b); + b = y.s; + + // Either NaN? + if (!a || !b) return new BigNumber(NaN); + + // Signs differ? + if (a != b) { + y.s = -b; + return x.minus(y); + } + + var xe = x.e / LOG_BASE, + ye = y.e / LOG_BASE, + xc = x.c, + yc = y.c; + + if (!xe || !ye) { + + // Return ±Infinity if either ±Infinity. + if (!xc || !yc) return new BigNumber(a / 0); + + // Either zero? + // Return y if y is non-zero, x if x is non-zero, or zero if both are zero. + if (!xc[0] || !yc[0]) return yc[0] ? y : new BigNumber(xc[0] ? x : a * 0); + } + + xe = bitFloor(xe); + ye = bitFloor(ye); + xc = xc.slice(); + + // Prepend zeros to equalise exponents. Faster to use reverse then do unshifts. + if (a = xe - ye) { + if (a > 0) { + ye = xe; + t = yc; + } else { + a = -a; + t = xc; + } + + t.reverse(); + for (; a--; t.push(0)); + t.reverse(); + } + + a = xc.length; + b = yc.length; + + // Point xc to the longer array, and b to the shorter length. + if (a - b < 0) { + t = yc; + yc = xc; + xc = t; + b = a; + } + + // Only start adding at yc.length - 1 as the further digits of xc can be ignored. + for (a = 0; b;) { + a = (xc[--b] = xc[b] + yc[b] + a) / BASE | 0; + xc[b] = BASE === xc[b] ? 0 : xc[b] % BASE; + } + + if (a) { + xc = [a].concat(xc); + ++ye; + } + + // No need to check for zero, as +x + +y != 0 && -x + -y != 0 + // ye = MAX_EXP + 1 possible + return normalise(y, xc, ye); + }; + + + /* + * If sd is undefined or null or true or false, return the number of significant digits of + * the value of this BigNumber, or null if the value of this BigNumber is ±Infinity or NaN. + * If sd is true include integer-part trailing zeros in the count. + * + * Otherwise, if sd is a number, return a new BigNumber whose value is the value of this + * BigNumber rounded to a maximum of sd significant digits using rounding mode rm, or + * ROUNDING_MODE if rm is omitted. + * + * sd {number|boolean} number: significant digits: integer, 1 to MAX inclusive. + * boolean: whether to count integer-part trailing zeros: true or false. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' + */ + P.precision = P.sd = function (sd, rm) { + var c, n, v, + x = this; + + if (sd != null && sd !== !!sd) { + intCheck(sd, 1, MAX); + if (rm == null) rm = ROUNDING_MODE; + else intCheck(rm, 0, 8); + + return round(new BigNumber(x), sd, rm); + } + + if (!(c = x.c)) return null; + v = c.length - 1; + n = v * LOG_BASE + 1; + + if (v = c[v]) { + + // Subtract the number of trailing zeros of the last element. + for (; v % 10 == 0; v /= 10, n--); + + // Add the number of digits of the first element. + for (v = c[0]; v >= 10; v /= 10, n++); + } + + if (sd && x.e + 1 > n) n = x.e + 1; + + return n; + }; + + + /* + * Return a new BigNumber whose value is the value of this BigNumber shifted by k places + * (powers of 10). Shift to the right if n > 0, and to the left if n < 0. + * + * k {number} Integer, -MAX_SAFE_INTEGER to MAX_SAFE_INTEGER inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {k}' + */ + P.shiftedBy = function (k) { + intCheck(k, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER); + return this.times('1e' + k); + }; + + + /* + * sqrt(-n) = N + * sqrt(N) = N + * sqrt(-I) = N + * sqrt(I) = I + * sqrt(0) = 0 + * sqrt(-0) = -0 + * + * Return a new BigNumber whose value is the square root of the value of this BigNumber, + * rounded according to DECIMAL_PLACES and ROUNDING_MODE. + */ + P.squareRoot = P.sqrt = function () { + var m, n, r, rep, t, + x = this, + c = x.c, + s = x.s, + e = x.e, + dp = DECIMAL_PLACES + 4, + half = new BigNumber('0.5'); + + // Negative/NaN/Infinity/zero? + if (s !== 1 || !c || !c[0]) { + return new BigNumber(!s || s < 0 && (!c || c[0]) ? NaN : c ? x : 1 / 0); + } + + // Initial estimate. + s = Math.sqrt(+valueOf(x)); + + // Math.sqrt underflow/overflow? + // Pass x to Math.sqrt as integer, then adjust the exponent of the result. + if (s == 0 || s == 1 / 0) { + n = coeffToString(c); + if ((n.length + e) % 2 == 0) n += '0'; + s = Math.sqrt(+n); + e = bitFloor((e + 1) / 2) - (e < 0 || e % 2); + + if (s == 1 / 0) { + n = '5e' + e; + } else { + n = s.toExponential(); + n = n.slice(0, n.indexOf('e') + 1) + e; + } + + r = new BigNumber(n); + } else { + r = new BigNumber(s + ''); + } + + // Check for zero. + // r could be zero if MIN_EXP is changed after the this value was created. + // This would cause a division by zero (x/t) and hence Infinity below, which would cause + // coeffToString to throw. + if (r.c[0]) { + e = r.e; + s = e + dp; + if (s < 3) s = 0; + + // Newton-Raphson iteration. + for (; ;) { + t = r; + r = half.times(t.plus(div(x, t, dp, 1))); + + if (coeffToString(t.c).slice(0, s) === (n = coeffToString(r.c)).slice(0, s)) { + + // The exponent of r may here be one less than the final result exponent, + // e.g 0.0009999 (e-4) --> 0.001 (e-3), so adjust s so the rounding digits + // are indexed correctly. + if (r.e < e) --s; + n = n.slice(s - 3, s + 1); + + // The 4th rounding digit may be in error by -1 so if the 4 rounding digits + // are 9999 or 4999 (i.e. approaching a rounding boundary) continue the + // iteration. + if (n == '9999' || !rep && n == '4999') { + + // On the first iteration only, check to see if rounding up gives the + // exact result as the nines may infinitely repeat. + if (!rep) { + round(t, t.e + DECIMAL_PLACES + 2, 0); + + if (t.times(t).eq(x)) { + r = t; + break; + } + } + + dp += 4; + s += 4; + rep = 1; + } else { + + // If rounding digits are null, 0{0,4} or 50{0,3}, check for exact + // result. If not, then there are further digits and m will be truthy. + if (!+n || !+n.slice(1) && n.charAt(0) == '5') { + + // Truncate to the first rounding digit. + round(r, r.e + DECIMAL_PLACES + 2, 1); + m = !r.times(r).eq(x); + } + + break; + } + } + } + } + + return round(r, r.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m); + }; + + + /* + * Return a string representing the value of this BigNumber in exponential notation and + * rounded using ROUNDING_MODE to dp fixed decimal places. + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.toExponential = function (dp, rm) { + if (dp != null) { + intCheck(dp, 0, MAX); + dp++; + } + return format(this, dp, rm, 1); + }; + + + /* + * Return a string representing the value of this BigNumber in fixed-point notation rounding + * to dp fixed decimal places using rounding mode rm, or ROUNDING_MODE if rm is omitted. + * + * Note: as with JavaScript's number type, (-0).toFixed(0) is '0', + * but e.g. (-0.00001).toFixed(0) is '-0'. + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + */ + P.toFixed = function (dp, rm) { + if (dp != null) { + intCheck(dp, 0, MAX); + dp = dp + this.e + 1; + } + return format(this, dp, rm); + }; + + + /* + * Return a string representing the value of this BigNumber in fixed-point notation rounded + * using rm or ROUNDING_MODE to dp decimal places, and formatted according to the properties + * of the format or FORMAT object (see BigNumber.set). + * + * The formatting object may contain some or all of the properties shown below. + * + * FORMAT = { + * prefix: '', + * groupSize: 3, + * secondaryGroupSize: 0, + * groupSeparator: ',', + * decimalSeparator: '.', + * fractionGroupSize: 0, + * fractionGroupSeparator: '\xA0', // non-breaking space + * suffix: '' + * }; + * + * [dp] {number} Decimal places. Integer, 0 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * [format] {object} Formatting options. See FORMAT pbject above. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {dp|rm}' + * '[BigNumber Error] Argument not an object: {format}' + */ + P.toFormat = function (dp, rm, format) { + var str, + x = this; + + if (format == null) { + if (dp != null && rm && typeof rm == 'object') { + format = rm; + rm = null; + } else if (dp && typeof dp == 'object') { + format = dp; + dp = rm = null; + } else { + format = FORMAT; + } + } else if (typeof format != 'object') { + throw Error + (bignumberError + 'Argument not an object: ' + format); + } + + str = x.toFixed(dp, rm); + + if (x.c) { + var i, + arr = str.split('.'), + g1 = +format.groupSize, + g2 = +format.secondaryGroupSize, + groupSeparator = format.groupSeparator || '', + intPart = arr[0], + fractionPart = arr[1], + isNeg = x.s < 0, + intDigits = isNeg ? intPart.slice(1) : intPart, + len = intDigits.length; + + if (g2) { + i = g1; + g1 = g2; + g2 = i; + len -= i; + } + + if (g1 > 0 && len > 0) { + i = len % g1 || g1; + intPart = intDigits.substr(0, i); + for (; i < len; i += g1) intPart += groupSeparator + intDigits.substr(i, g1); + if (g2 > 0) intPart += groupSeparator + intDigits.slice(i); + if (isNeg) intPart = '-' + intPart; + } + + str = fractionPart + ? intPart + (format.decimalSeparator || '') + ((g2 = +format.fractionGroupSize) + ? fractionPart.replace(new RegExp('\\d{' + g2 + '}\\B', 'g'), + '$&' + (format.fractionGroupSeparator || '')) + : fractionPart) + : intPart; + } + + return (format.prefix || '') + str + (format.suffix || ''); + }; + + + /* + * Return an array of two BigNumbers representing the value of this BigNumber as a simple + * fraction with an integer numerator and an integer denominator. + * The denominator will be a positive non-zero value less than or equal to the specified + * maximum denominator. If a maximum denominator is not specified, the denominator will be + * the lowest value necessary to represent the number exactly. + * + * [md] {number|string|BigNumber} Integer >= 1, or Infinity. The maximum denominator. + * + * '[BigNumber Error] Argument {not an integer|out of range} : {md}' + */ + P.toFraction = function (md) { + var d, d0, d1, d2, e, exp, n, n0, n1, q, r, s, + x = this, + xc = x.c; + + if (md != null) { + n = new BigNumber(md); + + // Throw if md is less than one or is not an integer, unless it is Infinity. + if (!n.isInteger() && (n.c || n.s !== 1) || n.lt(ONE)) { + throw Error + (bignumberError + 'Argument ' + + (n.isInteger() ? 'out of range: ' : 'not an integer: ') + valueOf(n)); + } + } + + if (!xc) return new BigNumber(x); + + d = new BigNumber(ONE); + n1 = d0 = new BigNumber(ONE); + d1 = n0 = new BigNumber(ONE); + s = coeffToString(xc); + + // Determine initial denominator. + // d is a power of 10 and the minimum max denominator that specifies the value exactly. + e = d.e = s.length - x.e - 1; + d.c[0] = POWS_TEN[(exp = e % LOG_BASE) < 0 ? LOG_BASE + exp : exp]; + md = !md || n.comparedTo(d) > 0 ? (e > 0 ? d : n1) : n; + + exp = MAX_EXP; + MAX_EXP = 1 / 0; + n = new BigNumber(s); + + // n0 = d1 = 0 + n0.c[0] = 0; + + for (; ;) { + q = div(n, d, 0, 1); + d2 = d0.plus(q.times(d1)); + if (d2.comparedTo(md) == 1) break; + d0 = d1; + d1 = d2; + n1 = n0.plus(q.times(d2 = n1)); + n0 = d2; + d = n.minus(q.times(d2 = d)); + n = d2; + } + + d2 = div(md.minus(d0), d1, 0, 1); + n0 = n0.plus(d2.times(n1)); + d0 = d0.plus(d2.times(d1)); + n0.s = n1.s = x.s; + e = e * 2; + + // Determine which fraction is closer to x, n0/d0 or n1/d1 + r = div(n1, d1, e, ROUNDING_MODE).minus(x).abs().comparedTo( + div(n0, d0, e, ROUNDING_MODE).minus(x).abs()) < 1 ? [n1, d1] : [n0, d0]; + + MAX_EXP = exp; + + return r; + }; + + + /* + * Return the value of this BigNumber converted to a number primitive. + */ + P.toNumber = function () { + return +valueOf(this); + }; + + + /* + * Return a string representing the value of this BigNumber rounded to sd significant digits + * using rounding mode rm or ROUNDING_MODE. If sd is less than the number of digits + * necessary to represent the integer part of the value in fixed-point notation, then use + * exponential notation. + * + * [sd] {number} Significant digits. Integer, 1 to MAX inclusive. + * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive. + * + * '[BigNumber Error] Argument {not a primitive number|not an integer|out of range}: {sd|rm}' + */ + P.toPrecision = function (sd, rm) { + if (sd != null) intCheck(sd, 1, MAX); + return format(this, sd, rm, 2); + }; + + + /* + * Return a string representing the value of this BigNumber in base b, or base 10 if b is + * omitted. If a base is specified, including base 10, round according to DECIMAL_PLACES and + * ROUNDING_MODE. If a base is not specified, and this BigNumber has a positive exponent + * that is equal to or greater than TO_EXP_POS, or a negative exponent equal to or less than + * TO_EXP_NEG, return exponential notation. + * + * [b] {number} Integer, 2 to ALPHABET.length inclusive. + * + * '[BigNumber Error] Base {not a primitive number|not an integer|out of range}: {b}' + */ + P.toString = function (b) { + var str, + n = this, + s = n.s, + e = n.e; + + // Infinity or NaN? + if (e === null) { + if (s) { + str = 'Infinity'; + if (s < 0) str = '-' + str; + } else { + str = 'NaN'; + } + } else { + if (b == null) { + str = e <= TO_EXP_NEG || e >= TO_EXP_POS + ? toExponential(coeffToString(n.c), e) + : toFixedPoint(coeffToString(n.c), e, '0'); + } else if (b === 10 && alphabetHasNormalDecimalDigits) { + n = round(new BigNumber(n), DECIMAL_PLACES + e + 1, ROUNDING_MODE); + str = toFixedPoint(coeffToString(n.c), n.e, '0'); + } else { + intCheck(b, 2, ALPHABET.length, 'Base'); + str = convertBase(toFixedPoint(coeffToString(n.c), e, '0'), 10, b, s, true); + } + + if (s < 0 && n.c[0]) str = '-' + str; + } + + return str; + }; + + + /* + * Return as toString, but do not accept a base argument, and include the minus sign for + * negative zero. + */ + P.valueOf = P.toJSON = function () { + return valueOf(this); + }; + + + P._isBigNumber = true; + + if (configObject != null) BigNumber.set(configObject); + + return BigNumber; + } + + + // PRIVATE HELPER FUNCTIONS + + // These functions don't need access to variables, + // e.g. DECIMAL_PLACES, in the scope of the `clone` function above. + + + function bitFloor(n) { + var i = n | 0; + return n > 0 || n === i ? i : i - 1; + } + + + // Return a coefficient array as a string of base 10 digits. + function coeffToString(a) { + var s, z, + i = 1, + j = a.length, + r = a[0] + ''; + + for (; i < j;) { + s = a[i++] + ''; + z = LOG_BASE - s.length; + for (; z--; s = '0' + s); + r += s; + } + + // Determine trailing zeros. + for (j = r.length; r.charCodeAt(--j) === 48;); + + return r.slice(0, j + 1 || 1); + } + + + // Compare the value of BigNumbers x and y. + function compare(x, y) { + var a, b, + xc = x.c, + yc = y.c, + i = x.s, + j = y.s, + k = x.e, + l = y.e; + + // Either NaN? + if (!i || !j) return null; + + a = xc && !xc[0]; + b = yc && !yc[0]; + + // Either zero? + if (a || b) return a ? b ? 0 : -j : i; + + // Signs differ? + if (i != j) return i; + + a = i < 0; + b = k == l; + + // Either Infinity? + if (!xc || !yc) return b ? 0 : !xc ^ a ? 1 : -1; + + // Compare exponents. + if (!b) return k > l ^ a ? 1 : -1; + + j = (k = xc.length) < (l = yc.length) ? k : l; + + // Compare digit by digit. + for (i = 0; i < j; i++) if (xc[i] != yc[i]) return xc[i] > yc[i] ^ a ? 1 : -1; + + // Compare lengths. + return k == l ? 0 : k > l ^ a ? 1 : -1; + } + + + /* + * Check that n is a primitive number, an integer, and in range, otherwise throw. + */ + function intCheck(n, min, max, name) { + if (n < min || n > max || n !== mathfloor(n)) { + throw Error + (bignumberError + (name || 'Argument') + (typeof n == 'number' + ? n < min || n > max ? ' out of range: ' : ' not an integer: ' + : ' not a primitive number: ') + String(n)); + } + } + + + // Assumes finite n. + function isOdd(n) { + var k = n.c.length - 1; + return bitFloor(n.e / LOG_BASE) == k && n.c[k] % 2 != 0; + } + + + function toExponential(str, e) { + return (str.length > 1 ? str.charAt(0) + '.' + str.slice(1) : str) + + (e < 0 ? 'e' : 'e+') + e; + } + + + function toFixedPoint(str, e, z) { + var len, zs; + + // Negative exponent? + if (e < 0) { + + // Prepend zeros. + for (zs = z + '.'; ++e; zs += z); + str = zs + str; + + // Positive exponent + } else { + len = str.length; + + // Append zeros. + if (++e > len) { + for (zs = z, e -= len; --e; zs += z); + str += zs; + } else if (e < len) { + str = str.slice(0, e) + '.' + str.slice(e); + } + } + + return str; + } + + + // EXPORT + + + BigNumber = clone(); + BigNumber['default'] = BigNumber.BigNumber = BigNumber; + + // AMD. + if (typeof define == 'function' && define.amd) { + define(function () { return BigNumber; }); + + // Node.js and other environments that support module.exports. + } else if (typeof module != 'undefined' && module.exports) { + module.exports = BigNumber; + + // Browser. + } else { + if (!globalObject) { + globalObject = typeof self != 'undefined' && self ? self : window; + } + + globalObject.BigNumber = BigNumber; + } + })(this); \ No newline at end of file diff --git a/wp-includes/lib/bignumber.js@9.1.0/bignumber.min.js b/wp-includes/lib/bignumber.js@9.1.0/bignumber.min.js new file mode 100644 index 0000000..cb7b236 --- /dev/null +++ b/wp-includes/lib/bignumber.js@9.1.0/bignumber.min.js @@ -0,0 +1,7 @@ +/** + * Minified by jsDelivr using Terser v5.14.1. + * Original file: /npm/bignumber.js@9.1.0/bignumber.js + * + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files + */ +!function(e){"use strict";var r,n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,t=Math.ceil,i=Math.floor,o="[BigNumber Error] ",s=o+"Number primitive has more than 15 significant digits: ",f=1e14,u=14,l=9007199254740991,c=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],a=1e7,h=1e9;function g(e){var r=0|e;return e>0||e===r?r:r-1}function p(e){for(var r,n,t=1,i=e.length,o=e[0]+"";tl^n?1:-1;for(f=(u=i.length)<(l=o.length)?u:l,s=0;so[s]^n?1:-1;return u==l?0:u>l^n?1:-1}function d(e,r,n,t){if(en||e!==i(e))throw Error(o+(t||"Argument")+("number"==typeof e?en?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function m(e){var r=e.c.length-1;return g(e.e/u)==r&&e.c[r]%2!=0}function v(e,r){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function N(e,r,n){var t,i;if(r<0){for(i=n+".";++r;i+=n);e=i+e}else if(++r>(t=e.length)){for(i=n,r-=t;--r;i+=n);e+=i}else rM?w.c=w.e=null:e.e=10;a/=10,c++);return void(c>M?w.c=w.e=null:(w.e=c,w.c=[e]))}p=String(e)}else{if(!n.test(p=String(e)))return b(w,p,h);w.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(c=p.indexOf("."))>-1&&(p=p.replace(".","")),(a=p.search(/e/i))>0?(c<0&&(c=a),c+=+p.slice(a+1),p=p.substring(0,a)):c<0&&(c=p.length)}else{if(d(r,2,j.length,"Base"),10==r&&$)return X(w=new z(e),L+w.e+1,U);if(p=String(e),h="number"==typeof e){if(0*e!=0)return b(w,p,h,r);if(w.s=1/e<0?(p=p.slice(1),-1):1,z.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(s+e)}else w.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(t=j.slice(0,r),c=a=0,g=p.length;ac){c=g;continue}}else if(!f&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){f=!0,a=-1,c=0;continue}return b(w,String(e),h,r)}h=!1,(c=(p=y(p,r,10,w.s)).indexOf("."))>-1?p=p.replace(".",""):c=p.length}for(a=0;48===p.charCodeAt(a);a++);for(g=p.length;48===p.charCodeAt(--g););if(p=p.slice(a,++g)){if(g-=a,h&&z.DEBUG&&g>15&&(e>l||e!==i(e)))throw Error(s+w.s*e);if((c=c-a-1)>M)w.c=w.e=null;else if(c=T)?v(u,s):N(u,s,"0");else if(o=(e=X(new z(e),r,n)).e,f=(u=p(e.c)).length,1==t||2==t&&(r<=o||o<=I)){for(;ff){if(--r>0)for(u+=".";r--;u+="0");}else if((r+=o-f)>0)for(o+1==f&&(u+=".");r--;u+="0");return e.s<0&&i?"-"+u:u}function V(e,r){for(var n,t=1,i=new z(e[0]);t=10;i/=10,t++);return(n=t+n*u-1)>M?e.c=e.e=null:n=10;h/=10,s++);if((l=r-s)<0)l+=u,a=r,w=(g=d[p=0])/m[s-a-1]%10|0;else if((p=t((l+1)/u))>=d.length){if(!o)break e;for(;d.length<=p;d.push(0));g=w=0,s=1,a=(l%=u)-u+1}else{for(g=h=d[p],s=1;h>=10;h/=10,s++);w=(a=(l%=u)-u+s)<0?0:g/m[s-a-1]%10|0}if(o=o||r<0||null!=d[p+1]||(a<0?g:g%m[s-a-1]),o=n<4?(w||o)&&(0==n||n==(e.s<0?3:2)):w>5||5==w&&(4==n||o||6==n&&(l>0?a>0?g/m[s-a]:0:d[p-1])%10&1||n==(e.s<0?8:7)),r<1||!d[0])return d.length=0,o?(r-=e.e+1,d[0]=m[(u-r%u)%u],e.e=-r||0):d[0]=e.e=0,e;if(0==l?(d.length=p,h=1,p--):(d.length=p+1,h=m[u-l],d[p]=a>0?i(g/m[s-a]%m[a])*h:0),o)for(;;){if(0==p){for(l=1,a=d[0];a>=10;a/=10,l++);for(a=d[0]+=h,h=1;a>=10;a/=10,h++);l!=h&&(e.e++,d[0]==f&&(d[0]=1));break}if(d[p]+=h,d[p]!=f)break;d[p--]=0,h=1}for(l=d.length;0===d[--l];d.pop());}e.e>M?e.c=e.e=null:e.e=T?v(r,n):N(r,n,"0"),e.s<0?"-"+r:r)}return z.clone=e,z.ROUND_UP=0,z.ROUND_DOWN=1,z.ROUND_CEIL=2,z.ROUND_FLOOR=3,z.ROUND_HALF_UP=4,z.ROUND_HALF_DOWN=5,z.ROUND_HALF_EVEN=6,z.ROUND_HALF_CEIL=7,z.ROUND_HALF_FLOOR=8,z.EUCLID=9,z.config=z.set=function(e){var r,n;if(null!=e){if("object"!=typeof e)throw Error(o+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(d(n=e[r],0,h,r),L=n),e.hasOwnProperty(r="ROUNDING_MODE")&&(d(n=e[r],0,8,r),U=n),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((n=e[r])&&n.pop?(d(n[0],-h,0,r),d(n[1],0,h,r),I=n[0],T=n[1]):(d(n,-h,h,r),I=-(T=n<0?-n:n))),e.hasOwnProperty(r="RANGE"))if((n=e[r])&&n.pop)d(n[0],-h,-1,r),d(n[1],1,h,r),C=n[0],M=n[1];else{if(d(n,-h,h,r),!n)throw Error(o+r+" cannot be zero: "+n);C=-(M=n<0?-n:n)}if(e.hasOwnProperty(r="CRYPTO")){if((n=e[r])!==!!n)throw Error(o+r+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw G=!n,Error(o+"crypto unavailable");G=n}else G=n}if(e.hasOwnProperty(r="MODULO_MODE")&&(d(n=e[r],0,9,r),k=n),e.hasOwnProperty(r="POW_PRECISION")&&(d(n=e[r],0,h,r),F=n),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(n=e[r]))throw Error(o+r+" not an object: "+n);q=n}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(n=e[r])||/^.?$|[+\-.\s]|(.).*\1/.test(n))throw Error(o+r+" invalid: "+n);$="0123456789"==n.slice(0,10),j=n}}return{DECIMAL_PLACES:L,ROUNDING_MODE:U,EXPONENTIAL_AT:[I,T],RANGE:[C,M],CRYPTO:G,MODULO_MODE:k,POW_PRECISION:F,FORMAT:q,ALPHABET:j}},z.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!z.DEBUG)return!0;var r,n,t=e.c,s=e.e,l=e.s;e:if("[object Array]"=={}.toString.call(t)){if((1===l||-1===l)&&s>=-h&&s<=h&&s===i(s)){if(0===t[0]){if(0===s&&1===t.length)return!0;break e}if((r=(s+1)%u)<1&&(r+=u),String(t[0]).length==r){for(r=0;r=f||n!==i(n))break e;if(0!==n)return!0}}}else if(null===t&&null===s&&(null===l||1===l||-1===l))return!0;throw Error(o+"Invalid BigNumber: "+e)},z.maximum=z.max=function(){return V(arguments,P.lt)},z.minimum=z.min=function(){return V(arguments,P.gt)},z.random=(E=9007199254740992,A=Math.random()*E&2097151?function(){return i(Math.random()*E)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,n,s,f,l,a=0,g=[],p=new z(x);if(null==e?e=L:d(e,0,h),f=t(e/u),G)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(f*=2));a>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[a]=n[0],r[a+1]=n[1]):(g.push(l%1e14),a+=2);a=f/2}else{if(!crypto.randomBytes)throw G=!1,Error(o+"crypto unavailable");for(r=crypto.randomBytes(f*=7);a=9e15?crypto.randomBytes(7).copy(r,a):(g.push(l%1e14),a+=7);a=f/7}if(!G)for(;a=10;l/=10,a++);an-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(n,t,i,o,s){var f,u,l,c,a,h,g,w,d=n.indexOf("."),m=L,v=U;for(d>=0&&(c=F,F=0,n=n.replace(".",""),h=(w=new z(t)).pow(n.length-d),F=c,w.c=r(N(p(h.c),h.e,"0"),10,i,e),w.e=w.c.length),l=c=(g=r(n,t,i,s?(f=j,e):(f=e,j))).length;0==g[--c];g.pop());if(!g[0])return f.charAt(0);if(d<0?--l:(h.c=g,h.e=l,h.s=o,g=(h=O(h,w,m,v,i)).c,a=h.r,l=h.e),d=g[u=l+m+1],c=i/2,a=a||u<0||null!=g[u+1],a=v<4?(null!=d||a)&&(0==v||v==(h.s<0?3:2)):d>c||d==c&&(4==v||a||6==v&&1&g[u-1]||v==(h.s<0?8:7)),u<1||!g[0])n=a?N(f.charAt(1),-m,f.charAt(0)):f.charAt(0);else{if(g.length=u,a)for(--i;++g[--u]>i;)g[u]=0,u||(++l,g=[1].concat(g));for(c=g.length;!g[--c];);for(d=0,n="";d<=c;n+=f.charAt(g[d++]));n=N(n,l,f.charAt(0))}return n}}(),O=function(){function e(e,r,n){var t,i,o,s,f=0,u=e.length,l=r%a,c=r/a|0;for(e=e.slice();u--;)f=((i=l*(o=e[u]%a)+(t=c*o+(s=e[u]/a|0)*l)%a*a+f)/n|0)+(t/a|0)+c*s,e[u]=i%n;return f&&(e=[f].concat(e)),e}function r(e,r,n,t){var i,o;if(n!=t)o=n>t?1:-1;else for(i=o=0;ir[i]?1:-1;break}return o}function n(e,r,n,t){for(var i=0;n--;)e[n]-=i,i=e[n]1;e.splice(0,1));}return function(t,o,s,l,c){var a,h,p,w,d,m,v,N,O,y,b,E,A,S,R,_,B,D=t.s==o.s?1:-1,P=t.c,x=o.c;if(!(P&&P[0]&&x&&x[0]))return new z(t.s&&o.s&&(P?!x||P[0]!=x[0]:x)?P&&0==P[0]||!x?0*D:D/0:NaN);for(O=(N=new z(D)).c=[],D=s+(h=t.e-o.e)+1,c||(c=f,h=g(t.e/u)-g(o.e/u),D=D/u|0),p=0;x[p]==(P[p]||0);p++);if(x[p]>(P[p]||0)&&h--,D<0)O.push(1),w=!0;else{for(S=P.length,_=x.length,p=0,D+=2,(d=i(c/(x[0]+1)))>1&&(x=e(x,d,c),P=e(P,d,c),_=x.length,S=P.length),A=_,b=(y=P.slice(0,_)).length;b<_;y[b++]=0);B=x.slice(),B=[0].concat(B),R=x[0],x[1]>=c/2&&R++;do{if(d=0,(a=r(x,y,_,b))<0){if(E=y[0],_!=b&&(E=E*c+(y[1]||0)),(d=i(E/R))>1)for(d>=c&&(d=c-1),v=(m=e(x,d,c)).length,b=y.length;1==r(m,y,v,b);)d--,n(m,_=10;D/=10,p++);X(N,s+(N.e=p+h*u-1)+1,l,w)}else N.e=h,N.r=+w;return N}}(),S=/^(-?)0([xbo])(?=\w[\w.]*$)/i,R=/^([^.]+)\.$/,_=/^\.([^.]+)$/,B=/^-?(Infinity|NaN)$/,D=/^\s*\+(?=[\w.])|^\s+|\s+$/g,b=function(e,r,n,t){var i,s=n?r:r.replace(D,"");if(B.test(s))e.s=isNaN(s)?null:s<0?-1:1;else{if(!n&&(s=s.replace(S,(function(e,r,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,t&&t!=i?e:r})),t&&(i=t,s=s.replace(R,"$1").replace(_,"0.$1")),r!=s))return new z(s,i);if(z.DEBUG)throw Error(o+"Not a"+(t?" base "+t:"")+" number: "+r);e.s=null}e.c=e.e=null},P.absoluteValue=P.abs=function(){var e=new z(this);return e.s<0&&(e.s=1),e},P.comparedTo=function(e,r){return w(this,new z(e,r))},P.decimalPlaces=P.dp=function(e,r){var n,t,i,o=this;if(null!=e)return d(e,0,h),null==r?r=U:d(r,0,8),X(new z(o),e+o.e+1,r);if(!(n=o.c))return null;if(t=((i=n.length-1)-g(this.e/u))*u,i=n[i])for(;i%10==0;i/=10,t--);return t<0&&(t=0),t},P.dividedBy=P.div=function(e,r){return O(this,new z(e,r),L,U)},P.dividedToIntegerBy=P.idiv=function(e,r){return O(this,new z(e,r),0,1)},P.exponentiatedBy=P.pow=function(e,r){var n,s,f,l,c,a,h,g,p=this;if((e=new z(e)).c&&!e.isInteger())throw Error(o+"Exponent not an integer: "+Y(e));if(null!=r&&(r=new z(r)),c=e.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!e.c||!e.c[0])return g=new z(Math.pow(+Y(p),c?2-m(e):+Y(e))),r?g.mod(r):g;if(a=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new z(NaN);(s=!a&&p.isInteger()&&r.isInteger())&&(p=p.mod(r))}else{if(e.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||c&&p.c[1]>=24e7:p.c[0]<8e13||c&&p.c[0]<=9999975e7)))return l=p.s<0&&m(e)?-0:0,p.e>-1&&(l=1/l),new z(a?1/l:l);F&&(l=t(F/u+2))}for(c?(n=new z(.5),a&&(e.s=1),h=m(e)):h=(f=Math.abs(+Y(e)))%2,g=new z(x);;){if(h){if(!(g=g.times(p)).c)break;l?g.c.length>l&&(g.c.length=l):s&&(g=g.mod(r))}if(f){if(0===(f=i(f/2)))break;h=f%2}else if(X(e=e.times(n),e.e+1,1),e.e>14)h=m(e);else{if(0===(f=+Y(e)))break;h=f%2}p=p.times(p),l?p.c&&p.c.length>l&&(p.c.length=l):s&&(p=p.mod(r))}return s?g:(a&&(g=x.div(g)),r?g.mod(r):l?X(g,F,U,undefined):g)},P.integerValue=function(e){var r=new z(this);return null==e?e=U:d(e,0,8),X(r,r.e+1,e)},P.isEqualTo=P.eq=function(e,r){return 0===w(this,new z(e,r))},P.isFinite=function(){return!!this.c},P.isGreaterThan=P.gt=function(e,r){return w(this,new z(e,r))>0},P.isGreaterThanOrEqualTo=P.gte=function(e,r){return 1===(r=w(this,new z(e,r)))||0===r},P.isInteger=function(){return!!this.c&&g(this.e/u)>this.c.length-2},P.isLessThan=P.lt=function(e,r){return w(this,new z(e,r))<0},P.isLessThanOrEqualTo=P.lte=function(e,r){return-1===(r=w(this,new z(e,r)))||0===r},P.isNaN=function(){return!this.s},P.isNegative=function(){return this.s<0},P.isPositive=function(){return this.s>0},P.isZero=function(){return!!this.c&&0==this.c[0]},P.minus=function(e,r){var n,t,i,o,s=this,l=s.s;if(r=(e=new z(e,r)).s,!l||!r)return new z(NaN);if(l!=r)return e.s=-r,s.plus(e);var c=s.e/u,a=e.e/u,h=s.c,p=e.c;if(!c||!a){if(!h||!p)return h?(e.s=-r,e):new z(p?s:NaN);if(!h[0]||!p[0])return p[0]?(e.s=-r,e):new z(h[0]?s:3==U?-0:0)}if(c=g(c),a=g(a),h=h.slice(),l=c-a){for((o=l<0)?(l=-l,i=h):(a=c,i=p),i.reverse(),r=l;r--;i.push(0));i.reverse()}else for(t=(o=(l=h.length)<(r=p.length))?l:r,l=r=0;r0)for(;r--;h[n++]=0);for(r=f-1;t>l;){if(h[--t]=0;){for(n=0,d=E[i]%O,m=E[i]/O|0,o=i+(s=c);o>i;)n=((h=d*(h=b[--s]%O)+(l=m*h+(p=b[s]/O|0)*d)%O*O+v[o]+n)/N|0)+(l/O|0)+m*p,v[o--]=h%N;v[o]=n}return n?++t:v.splice(0,1),W(e,v,t)},P.negated=function(){var e=new z(this);return e.s=-e.s||null,e},P.plus=function(e,r){var n,t=this,i=t.s;if(r=(e=new z(e,r)).s,!i||!r)return new z(NaN);if(i!=r)return e.s=-r,t.minus(e);var o=t.e/u,s=e.e/u,l=t.c,c=e.c;if(!o||!s){if(!l||!c)return new z(i/0);if(!l[0]||!c[0])return c[0]?e:new z(l[0]?t:0*i)}if(o=g(o),s=g(s),l=l.slice(),i=o-s){for(i>0?(s=o,n=c):(i=-i,n=l),n.reverse();i--;n.push(0));n.reverse()}for((i=l.length)-(r=c.length)<0&&(n=c,c=l,l=n,r=i),i=0;r;)i=(l[--r]=l[r]+c[r]+i)/f|0,l[r]=f===l[r]?0:l[r]%f;return i&&(l=[i].concat(l),++s),W(e,l,s)},P.precision=P.sd=function(e,r){var n,t,i,o=this;if(null!=e&&e!==!!e)return d(e,1,h),null==r?r=U:d(r,0,8),X(new z(o),e,r);if(!(n=o.c))return null;if(t=(i=n.length-1)*u+1,i=n[i]){for(;i%10==0;i/=10,t--);for(i=n[0];i>=10;i/=10,t++);}return e&&o.e+1>t&&(t=o.e+1),t},P.shiftedBy=function(e){return d(e,-9007199254740991,l),this.times("1e"+e)},P.squareRoot=P.sqrt=function(){var e,r,n,t,i,o=this,s=o.c,f=o.s,u=o.e,l=L+4,c=new z("0.5");if(1!==f||!s||!s[0])return new z(!f||f<0&&(!s||s[0])?NaN:s?o:1/0);if(0==(f=Math.sqrt(+Y(o)))||f==1/0?(((r=p(s)).length+u)%2==0&&(r+="0"),f=Math.sqrt(+r),u=g((u+1)/2)-(u<0||u%2),n=new z(r=f==1/0?"5e"+u:(r=f.toExponential()).slice(0,r.indexOf("e")+1)+u)):n=new z(f+""),n.c[0])for((f=(u=n.e)+l)<3&&(f=0);;)if(i=n,n=c.times(i.plus(O(o,i,l,1))),p(i.c).slice(0,f)===(r=p(n.c)).slice(0,f)){if(n.e0&&w>0){for(s=w%u||u,a=p.substr(0,s);s0&&(a+=c+p.slice(s)),g&&(a="-"+a)}t=h?a+(n.decimalSeparator||"")+((l=+n.fractionGroupSize)?h.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):h):a}return(n.prefix||"")+t+(n.suffix||"")},P.toFraction=function(e){var r,n,t,i,s,f,l,a,h,g,w,d,m=this,v=m.c;if(null!=e&&(!(l=new z(e)).isInteger()&&(l.c||1!==l.s)||l.lt(x)))throw Error(o+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+Y(l));if(!v)return new z(m);for(r=new z(x),h=n=new z(x),t=a=new z(x),d=p(v),s=r.e=d.length-m.e-1,r.c[0]=c[(f=s%u)<0?u+f:f],e=!e||l.comparedTo(r)>0?s>0?r:h:l,f=M,M=1/0,l=new z(d),a.c[0]=0;g=O(l,r,0,1),1!=(i=n.plus(g.times(t))).comparedTo(e);)n=t,t=i,h=a.plus(g.times(i=h)),a=i,r=l.minus(g.times(i=r)),l=i;return i=O(e.minus(n),t,0,1),a=a.plus(i.times(h)),n=n.plus(i.times(t)),a.s=h.s=m.s,w=O(h,t,s*=2,U).minus(m).abs().comparedTo(O(a,n,s,U).minus(m).abs())<1?[h,t]:[a,n],M=f,w},P.toNumber=function(){return+Y(this)},P.toPrecision=function(e,r){return null!=e&&d(e,1,h),H(this,e,r,2)},P.toString=function(e){var r,n=this,t=n.s,i=n.e;return null===i?t?(r="Infinity",t<0&&(r="-"+r)):r="NaN":(null==e?r=i<=I||i>=T?v(p(n.c),i):N(p(n.c),i,"0"):10===e&&$?r=N(p((n=X(new z(n),L+i+1,U)).c),n.e,"0"):(d(e,2,j.length,"Base"),r=y(N(p(n.c),i,"0"),10,e,t,!0)),t<0&&n.c[0]&&(r="-"+r)),r},P.valueOf=P.toJSON=function(){return Y(this)},P._isBigNumber=!0,null!=r&&z.set(r),z}(),r.default=r.BigNumber=r,"function"==typeof define&&define.amd?define((function(){return r})):"undefined"!=typeof module&&module.exports?module.exports=r:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=r)}(this); diff --git a/wp-includes/lib/bignumber.js@9.1.0/github.txt b/wp-includes/lib/bignumber.js@9.1.0/github.txt new file mode 100644 index 0000000..327f398 --- /dev/null +++ b/wp-includes/lib/bignumber.js@9.1.0/github.txt @@ -0,0 +1,2 @@ +https://github.com/MikeMcl/bignumber.js/tree/v9.1.1 +https://cdn.jsdelivr.net/npm/bignumber.js@9.1.0/bignumber.js