Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@phensley/decimal

Package Overview
Dependencies
Maintainers
1
Versions
198
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@phensley/decimal - npm Package Compare versions

Comparing version 1.2.13 to 1.2.14

2

lib-es/decimal.d.ts

@@ -21,3 +21,3 @@ import { DecimalFormatter, Part } from './format';

*/
export declare type DecimalArg = number | string | Decimal;
export type DecimalArg = number | string | Decimal;
/**

@@ -24,0 +24,0 @@ * Converts a valid argument into a Decimal value.

@@ -52,4 +52,4 @@ import { add, divide, multiply, subtract, trimLeadingZeros, DivMod } from './math';

var size = function (n) {
var q = (n / 7 /* RDIGITS */) | 0;
var r = n - q * 7 /* RDIGITS */;
var q = (n / 7 /* Constants.RDIGITS */) | 0;
var r = n - q * 7 /* Constants.RDIGITS */;
return r === 0 ? q : q + 1;

@@ -67,3 +67,3 @@ };

this._exp = 0;
this.flag = 0 /* NONE */;
this.flag = 0 /* DecimalFlag.NONE */;
if (typeof num === 'string' || typeof num === 'number') {

@@ -89,3 +89,3 @@ this.parse(num);

Decimal.prototype.isNaN = function () {
return this.flag === 1 /* NAN */;
return this.flag === 1 /* DecimalFlag.NAN */;
};

@@ -102,3 +102,3 @@ /**

Decimal.prototype.isInfinity = function () {
return this.flag === 2 /* INFINITY */;
return this.flag === 2 /* DecimalFlag.INFINITY */;
};

@@ -122,3 +122,3 @@ /**

// NAN is never equal to itself or any other value
if (u.flag === 1 /* NAN */ || v.flag === 1 /* NAN */) {
if (u.flag === 1 /* DecimalFlag.NAN */ || v.flag === 1 /* DecimalFlag.NAN */) {
return -1;

@@ -133,3 +133,3 @@ }

// Positive infinity after all other values
return u.flag === 2 /* INFINITY */ ? (u.sign === -1 ? -1 : 1) : v.sign === -1 ? 1 : -1;
return u.flag === 2 /* DecimalFlag.INFINITY */ ? (u.sign === -1 ? -1 : 1) : v.sign === -1 ? 1 : -1;
}

@@ -234,3 +234,3 @@ u = u.stripTrailingZeros();

v = coerceDecimal(v);
var r = this.handleFlags(0 /* ADDITION */, v);
var r = this.handleFlags(0 /* Op.ADDITION */, v);
if (r === undefined) {

@@ -249,3 +249,3 @@ if (this.isZero()) {

v = coerceDecimal(v);
var r = this.handleFlags(1 /* SUBTRACTION */, v);
var r = this.handleFlags(1 /* Op.SUBTRACTION */, v);
if (r === undefined) {

@@ -265,3 +265,3 @@ if (this.isZero()) {

v = coerceDecimal(v);
var r = this.handleFlags(2 /* MULTIPLICATION */, v);
var r = this.handleFlags(2 /* Op.MULTIPLICATION */, v);
if (r !== undefined) {

@@ -302,3 +302,3 @@ return r;

v = coerceDecimal(v);
var r = this.handleFlags(3 /* DIVISION */, v);
var r = this.handleFlags(3 /* Op.DIVISION */, v);
if (r !== undefined) {

@@ -352,5 +352,5 @@ return r;

v = coerceDecimal(v);
var rq = this.handleFlags(3 /* DIVISION */, v);
var rq = this.handleFlags(3 /* Op.DIVISION */, v);
if (rq !== undefined) {
var rm = this.handleFlags(4 /* MOD */, v);
var rm = this.handleFlags(4 /* Op.MOD */, v);
return [rq, rm];

@@ -394,3 +394,3 @@ }

v = coerceDecimal(v);
var r = this.handleFlags(4 /* MOD */, v);
var r = this.handleFlags(4 /* Op.MOD */, v);
return r === undefined ? this.divmod(v)[1] : r;

@@ -411,3 +411,3 @@ };

var n = d[i];
r = i * 7 /* RDIGITS */;
r = i * 7 /* Constants.RDIGITS */;
while (n % 10 === 0) {

@@ -456,3 +456,3 @@ n /= 10 | 0;

var len = this.data.length;
return (len - 1) * 7 /* RDIGITS */ + digitCount(this.data[len - 1]);
return (len - 1) * 7 /* Constants.RDIGITS */ + digitCount(this.data[len - 1]);
};

@@ -563,3 +563,3 @@ /**

var r = this.formatString(coeff, minIntegers);
return coeff.isZero() ? r : exp === 0 ? r : r + ("E" + (exp > 0 ? '+' : '') + exp);
return coeff.isZero() ? r : exp === 0 ? r : r + "E".concat(exp > 0 ? '+' : '').concat(exp);
};

@@ -586,3 +586,3 @@ /**

var sign = exp < 0 ? { type: 'minus', value: '-' } : { type: 'plus', value: '+' };
return r.concat([{ type: 'exp', value: 'E' }, sign, { type: 'integer', value: "" + Math.abs(exp) }]);
return r.concat([{ type: 'exp', value: 'E' }, sign, { type: 'integer', value: "".concat(Math.abs(exp)) }]);
};

@@ -656,3 +656,3 @@ /**

var d = this.data[i];
var c = i === last ? digitCount(d) : 7 /* RDIGITS */;
var c = i === last ? digitCount(d) : 7 /* Constants.RDIGITS */;
// Loop over the decimal digits

@@ -703,5 +703,5 @@ for (var j = 0; j < c; j++) {

switch (this.flag) {
case 1 /* NAN */:
case 1 /* DecimalFlag.NAN */:
return 'NaN';
case 2 /* INFINITY */:
case 2 /* DecimalFlag.INFINITY */:
default:

@@ -713,5 +713,5 @@ return this.sign === 1 ? 'Infinity' : '-Infinity';

switch (this.flag) {
case 1 /* NAN */:
case 1 /* DecimalFlag.NAN */:
return [{ type: 'nan', value: 'NaN' }];
case 2 /* INFINITY */:
case 2 /* DecimalFlag.INFINITY */:
default:

@@ -756,11 +756,11 @@ var s = this.sign === 1 ? 'Infinity' : '-Infinity';

// Any operation involving a NAN returns a NAN
if (uflag === 1 /* NAN */ || vflag === 1 /* NAN */) {
if (uflag === 1 /* DecimalFlag.NAN */ || vflag === 1 /* DecimalFlag.NAN */) {
return NAN;
}
var uinf = uflag === 2 /* INFINITY */;
var vinf = vflag === 2 /* INFINITY */;
var uinf = uflag === 2 /* DecimalFlag.INFINITY */;
var vinf = vflag === 2 /* DecimalFlag.INFINITY */;
var uzero = u.isZero();
var vzero = v.isZero();
switch (op) {
case 0 /* ADDITION */:
case 0 /* Op.ADDITION */:
if (uinf && vinf) {

@@ -773,3 +773,3 @@ return u.sign === v.sign ? (u.sign === 1 ? POSITIVE_INFINITY : NEGATIVE_INFINITY) : NAN;

break;
case 1 /* SUBTRACTION */:
case 1 /* Op.SUBTRACTION */:
if (uinf && vinf) {

@@ -788,3 +788,3 @@ return u.sign === v.sign ? NAN : u.sign === 1 ? POSITIVE_INFINITY : NEGATIVE_INFINITY;

break;
case 2 /* MULTIPLICATION */:
case 2 /* Op.MULTIPLICATION */:
if (uinf) {

@@ -797,3 +797,3 @@ return vzero ? NAN : u.sign === v.sign ? POSITIVE_INFINITY : NEGATIVE_INFINITY;

break;
case 3 /* DIVISION */:
case 3 /* Op.DIVISION */:
if (uinf && vinf) {

@@ -818,3 +818,3 @@ return NAN;

break;
case 4 /* MOD */:
case 4 /* Op.MOD */:
if (uinf || vzero) {

@@ -849,4 +849,4 @@ return NAN;

// Compute the shift in terms of our radix.
var q = (shift / 7 /* RDIGITS */) | 0;
var r = shift - q * 7 /* RDIGITS */;
var q = (shift / 7 /* Constants.RDIGITS */) | 0;
var r = shift - q * 7 /* Constants.RDIGITS */;
// Expand w to hold shifted result and zero all elements.

@@ -865,3 +865,3 @@ var n = size(prec + shift);

var powlo = POWERS10[r];
var powhi = POWERS10[7 /* RDIGITS */ - r];
var powhi = POWERS10[7 /* Constants.RDIGITS */ - r];
var hi = 0;

@@ -914,3 +914,3 @@ var lo = 0;

var div = new DivMod();
var _d = div.word(shift, 7 /* RDIGITS */), q = _d[0], r = _d[1];
var _d = div.word(shift, 7 /* Constants.RDIGITS */), q = _d[0], r = _d[1];
var data = w.data.slice();

@@ -923,3 +923,3 @@ w.data.fill(0);

// q is always non-zero here, else there would be no shift
_a = div.pow10(data[q - 1], 7 /* RDIGITS */ - 1), rnd = _a[0], rest = _a[1];
_a = div.pow10(data[q - 1], 7 /* Constants.RDIGITS */ - 1), rnd = _a[0], rest = _a[1];
if (rest === 0) {

@@ -934,3 +934,3 @@ rest = allzero(data, q - 1) === 0 ? 1 : 0;

var hiprev = 0;
var ph = POWERS10[7 /* RDIGITS */ - r];
var ph = POWERS10[7 /* Constants.RDIGITS */ - r];
// q is always < data.length here; otherwise r == 0

@@ -1000,3 +1000,3 @@ _b = div.pow10(data[q], r), hiprev = _b[0], rest = _b[1];

s = d[i] + k;
k = s === 10000000 /* RADIX */ ? 1 : 0;
k = s === 10000000 /* Constants.RADIX */ ? 1 : 0;
d[i] = k ? 0 : s;

@@ -1096,7 +1096,7 @@ }

if (isNaN(arg)) {
this.flag = 1 /* NAN */;
this.flag = 1 /* DecimalFlag.NAN */;
return;
}
if (!isFinite(arg)) {
this.flag = 2 /* INFINITY */;
this.flag = 2 /* DecimalFlag.INFINITY */;
this.sign = arg === Infinity ? 1 : -1;

@@ -1123,7 +1123,7 @@ return;

if (NAN_VALUES.has(str)) {
this.flag = 1 /* NAN */;
this.flag = 1 /* DecimalFlag.NAN */;
return;
}
if (POS_INFINITY.has(str)) {
this.flag = 2 /* INFINITY */;
this.flag = 2 /* DecimalFlag.INFINITY */;
this.sign = 1;

@@ -1133,3 +1133,3 @@ return;

if (NEG_INFINITY.has(str)) {
this.flag = 2 /* INFINITY */;
this.flag = 2 /* DecimalFlag.INFINITY */;
this.sign = -1;

@@ -1158,6 +1158,6 @@ return;

switch (code) {
case 69 /* ELOWER */:
case 101 /* EUPPER */:
if (flags & 4 /* EXP */) {
return "Extra exponent character at " + i;
case 69 /* Chars.ELOWER */:
case 101 /* Chars.EUPPER */:
if (flags & 4 /* ParseFlags.EXP */) {
return "Extra exponent character at ".concat(i);
}

@@ -1172,4 +1172,4 @@ if (data.length > 0) {

// Indicate we have an exponent, and clear the sign flag.
flags |= 4 /* EXP */;
flags &= ~1 /* SIGN */;
flags |= 4 /* ParseFlags.EXP */;
flags &= ~1 /* ParseFlags.SIGN */;
// Copy the parsed number to the exponent and reset the digit count.

@@ -1182,34 +1182,34 @@ dig = 0;

break;
case 45 /* MINUS */:
case 43 /* PLUS */:
case 45 /* Chars.MINUS */:
case 43 /* Chars.PLUS */:
if (dig === 0) {
return 'Found a bare sign symbol';
}
if (flags & 1 /* SIGN */) {
return "Duplicate sign character at " + i;
if (flags & 1 /* ParseFlags.SIGN */) {
return "Duplicate sign character at ".concat(i);
}
sign = code === 45 /* MINUS */ ? -1 : 1;
flags |= 1 /* SIGN */;
sign = code === 45 /* Chars.MINUS */ ? -1 : 1;
flags |= 1 /* ParseFlags.SIGN */;
break;
case 46 /* DOT */:
if (flags & 2 /* POINT */) {
return "Extra radix point seen at " + i;
case 46 /* Chars.DOT */:
if (flags & 2 /* ParseFlags.POINT */) {
return "Extra radix point seen at ".concat(i);
}
flags |= 2 /* POINT */;
flags |= 2 /* ParseFlags.POINT */;
exp -= dig;
break;
case 48 /* DIGIT0 */:
case 49 /* DIGIT1 */:
case 50 /* DIGIT2 */:
case 51 /* DIGIT3 */:
case 52 /* DIGIT4 */:
case 53 /* DIGIT5 */:
case 54 /* DIGIT6 */:
case 55 /* DIGIT7 */:
case 56 /* DIGIT8 */:
case 57 /* DIGIT9 */:
n += (code - 48 /* DIGIT0 */) * POWERS10[z];
case 48 /* Chars.DIGIT0 */:
case 49 /* Chars.DIGIT1 */:
case 50 /* Chars.DIGIT2 */:
case 51 /* Chars.DIGIT3 */:
case 52 /* Chars.DIGIT4 */:
case 53 /* Chars.DIGIT5 */:
case 54 /* Chars.DIGIT6 */:
case 55 /* Chars.DIGIT7 */:
case 56 /* Chars.DIGIT8 */:
case 57 /* Chars.DIGIT9 */:
n += (code - 48 /* Chars.DIGIT0 */) * POWERS10[z];
z++;
dig++;
if (z === 7 /* RDIGITS */) {
if (z === 7 /* Constants.RDIGITS */) {
data.push(n);

@@ -1221,3 +1221,3 @@ n = 0;

default:
return "Unexpected character at " + i + ": " + str[i];
return "Unexpected character at ".concat(i, ": ").concat(str[i]);
}

@@ -1224,0 +1224,0 @@ i--;

@@ -19,5 +19,5 @@ import { POWERS10 } from './types';

var z = u[j] + vj + k;
w[j] = z % 10000000 /* RADIX */;
w[j] = z % 10000000 /* Constants.RADIX */;
// .. k is being set to 1 or 0, to carry
k = (z / 10000000 /* RADIX */) | 0;
k = (z / 10000000 /* Constants.RADIX */) | 0;
// A3. Loop on j

@@ -46,3 +46,3 @@ j++;

var z = u[j] - v[j] - k;
w[j] = z < 0 ? z + 10000000 /* RADIX */ : z;
w[j] = z < 0 ? z + 10000000 /* Constants.RADIX */ : z;
// k is set to 1 or 0, indicating a borrow

@@ -56,3 +56,3 @@ k = z < 0 ? 1 : 0;

var z = u[j] - k;
w[j] = z < 0 ? z + 10000000 /* RADIX */ : z;
w[j] = z < 0 ? z + 10000000 /* Constants.RADIX */ : z;
k = z < 0 ? 1 : 0;

@@ -89,4 +89,4 @@ j++;

var p = k + w[i + j] + u[i] * v[j];
k = (p / 10000000 /* RADIX */) | 0;
w[i + j] = p - k * 10000000 /* RADIX */;
k = (p / 10000000 /* Constants.RADIX */) | 0;
w[i + j] = p - k * 10000000 /* Constants.RADIX */;
// M5. Loop on i

@@ -111,4 +111,4 @@ i++;

var p = k + u[i] * v;
k = (p / 10000000 /* RADIX */) | 0;
w[i] = p - k * 10000000 /* RADIX */;
k = (p / 10000000 /* Constants.RADIX */) | 0;
w[i] = p - k * 10000000 /* Constants.RADIX */;
}

@@ -131,3 +131,3 @@ if (k > 0) {

if (nplusm < n) {
throw new Error("n + m must be >= n, got " + m);
throw new Error("n + m must be >= n, got ".concat(m));
}

@@ -144,3 +144,3 @@ // Storage for copy of u which is modified in place, and v which needs an

// D1. Normalize
var d = (10000000 /* RADIX */ / (v[n - 1] + 1)) | 0;
var d = (10000000 /* Constants.RADIX */ / (v[n - 1] + 1)) | 0;
if (d !== 1) {

@@ -157,3 +157,3 @@ multiplyword(u, uc, nplusm, d);

// D3. Calculate q̂ and r̂.
p = u[j + n - 1] + u[j + n] * 10000000 /* RADIX */;
p = u[j + n - 1] + u[j + n] * 10000000 /* Constants.RADIX */;
var qhat = (p / v[n - 1]) | 0;

@@ -163,6 +163,6 @@ var rhat = p - qhat * v[n - 1];

// D3. Test if q̂ = radix ...
if (qhat < 10000000 /* RADIX */) {
if (qhat < 10000000 /* Constants.RADIX */) {
var z = qhat * v[n - 2];
hi = (z / 10000000 /* RADIX */) | 0;
lo = z - hi * 10000000 /* RADIX */;
hi = (z / 10000000 /* Constants.RADIX */) | 0;
lo = z - hi * 10000000 /* Constants.RADIX */;
if (hi <= rhat) {

@@ -177,3 +177,3 @@ if (hi !== rhat || lo <= u[j + n - 2]) {

rhat += v[n - 1];
if (rhat >= 10000000 /* RADIX */) {
if (rhat >= 10000000 /* Constants.RADIX */) {
break;

@@ -188,8 +188,8 @@ }

p = qhat * v[i] + k;
hi = (p / 10000000 /* RADIX */) | 0;
lo = p - hi * 10000000 /* RADIX */;
hi = (p / 10000000 /* Constants.RADIX */) | 0;
lo = p - hi * 10000000 /* Constants.RADIX */;
// Subtract and determine carry.
var x = u[i + j] - lo;
k = x < 0 ? 1 : 0;
u[i + j] = k ? x + 10000000 /* RADIX */ : x;
u[i + j] = k ? x + 10000000 /* Constants.RADIX */ : x;
k += hi;

@@ -213,3 +213,3 @@ }

for (var i = n - 1; i >= 0; i--) {
p = u[i] + k * 10000000 /* RADIX */;
p = u[i] + k * 10000000 /* Constants.RADIX */;
r[i] = (p / d) | 0;

@@ -231,3 +231,3 @@ k = p - r[i] * d;

for (var i = n - 1; i >= 0; i--) {
var p = u[i] + r * 10000000 /* RADIX */;
var p = u[i] + r * 10000000 /* Constants.RADIX */;
q[i] = (p / v) | 0;

@@ -247,4 +247,4 @@ r = p - q[i] * v;

s = u[i + j] + (v[i] + k);
k = s >= 10000000 /* RADIX */ ? 1 : 0;
u[i + j] = k ? s - 10000000 /* RADIX */ : s;
k = s >= 10000000 /* Constants.RADIX */ ? 1 : 0;
u[i + j] = k ? s - 10000000 /* Constants.RADIX */ : s;
i++;

@@ -254,4 +254,4 @@ }

s = u[i + j] + k;
k = s === 10000000 /* RADIX */ ? 1 : /* istanbul ignore next */ 0;
u[i + j] = k === 1 ? s - 10000000 /* RADIX */ : /* istanbul ignore next */ s;
k = s === 10000000 /* Constants.RADIX */ ? 1 : /* istanbul ignore next */ 0;
u[i + j] = k === 1 ? s - 10000000 /* Constants.RADIX */ : /* istanbul ignore next */ s;
i++;

@@ -258,0 +258,0 @@ }

@@ -9,3 +9,3 @@ import { DivMod } from './math';

var m = b.length;
var _c = div.word(shift, 7 /* RDIGITS */), q = _c[0], r = _c[1];
var _c = div.word(shift, 7 /* Constants.RDIGITS */), q = _c[0], r = _c[1];
if (r === 0) {

@@ -27,3 +27,3 @@ while (--m >= 0) {

--n;
_a = div.pow10(b[m--], 7 /* RDIGITS */ - r), hi = _a[0], loprev = _a[1];
_a = div.pow10(b[m--], 7 /* Constants.RDIGITS */ - r), hi = _a[0], loprev = _a[1];
if (hi !== 0) {

@@ -38,3 +38,3 @@ c = cmp(a[n], hi);

for (; m >= 0; m--, n--) {
_b = div.pow10(b[m], 7 /* RDIGITS */ - r), hi = _b[0], lo = _b[1];
_b = div.pow10(b[m], 7 /* Constants.RDIGITS */ - r), hi = _b[0], lo = _b[1];
x = ph * loprev + hi;

@@ -69,13 +69,13 @@ c = cmp(a[n], x);

export var digitCount = function (w) {
if (w < 10000 /* P4 */) {
if (w < 100 /* P2 */) {
return w < 10 /* P1 */ ? 1 : 2;
if (w < 10000 /* Constants.P4 */) {
if (w < 100 /* Constants.P2 */) {
return w < 10 /* Constants.P1 */ ? 1 : 2;
}
return w < 1000 /* P3 */ ? 3 : 4;
return w < 1000 /* Constants.P3 */ ? 3 : 4;
}
if (w < 1000000 /* P6 */) {
return w < 100000 /* P5 */ ? 5 : 6;
if (w < 1000000 /* Constants.P6 */) {
return w < 100000 /* Constants.P5 */ ? 5 : 6;
}
return w < 10000000 /* P7 */ ? 7 : 8;
return w < 10000000 /* Constants.P7 */ ? 7 : 8;
};
//# sourceMappingURL=operations.js.map

@@ -8,3 +8,3 @@ import { Decimal, DecimalArg } from './decimal';

*/
export declare type RationalArg = Rational | Decimal | number | string;
export type RationalArg = Rational | Decimal | number | string;
/**

@@ -11,0 +11,0 @@ * Arbitrary precision rational type.

@@ -80,3 +80,3 @@ import { Decimal, DecimalConstants } from './decimal';

Rational.prototype.toString = function () {
return this.numer.toString() + " / " + this.denom.toString();
return "".concat(this.numer.toString(), " / ").concat(this.denom.toString());
};

@@ -83,0 +83,0 @@ Rational.prototype._parse = function (raw) {

@@ -16,3 +16,3 @@ /**

*/
export declare type RoundingModeType = 'up' | 'down' | 'ceiling' | 'floor' | 'half-up' | 'half-down' | 'half-even';
export type RoundingModeType = 'up' | 'down' | 'ceiling' | 'floor' | 'half-up' | 'half-down' | 'half-even';
/**

@@ -19,0 +19,0 @@ * Sets the scale or precision, and the rounding mode for a math operation.

export var POWERS10 = [
1 /* P0 */,
10 /* P1 */,
100 /* P2 */,
1000 /* P3 */,
10000 /* P4 */,
100000 /* P5 */,
1000000 /* P6 */,
10000000 /* P7 */,
100000000 /* P8 */,
1 /* Constants.P0 */,
10 /* Constants.P1 */,
100 /* Constants.P2 */,
1000 /* Constants.P3 */,
10000 /* Constants.P4 */,
100000 /* Constants.P5 */,
1000000 /* Constants.P6 */,
10000000 /* Constants.P7 */,
100000000 /* Constants.P8 */,
];
//# sourceMappingURL=types.js.map

@@ -21,3 +21,3 @@ import { DecimalFormatter, Part } from './format';

*/
export declare type DecimalArg = number | string | Decimal;
export type DecimalArg = number | string | Decimal;
/**

@@ -24,0 +24,0 @@ * Converts a valid argument into a Decimal value.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DecimalConstants = exports.Decimal = exports.coerceDecimal = exports.DECIMAL_DIGITS = void 0;
var math_1 = require("./math");

@@ -27,5 +28,6 @@ var operations_1 = require("./operations");

*/
exports.coerceDecimal = function (n) {
var coerceDecimal = function (n) {
return typeof n === 'number' || typeof n === 'string' ? new Decimal(n) : n;
};
exports.coerceDecimal = coerceDecimal;
/**

@@ -55,4 +57,4 @@ * Parses and interprets a math context argument, with appropriate defaults.

var size = function (n) {
var q = (n / 7 /* RDIGITS */) | 0;
var r = n - q * 7 /* RDIGITS */;
var q = (n / 7 /* Constants.RDIGITS */) | 0;
var r = n - q * 7 /* Constants.RDIGITS */;
return r === 0 ? q : q + 1;

@@ -70,3 +72,3 @@ };

this._exp = 0;
this.flag = 0 /* NONE */;
this.flag = 0 /* DecimalFlag.NONE */;
if (typeof num === 'string' || typeof num === 'number') {

@@ -92,3 +94,3 @@ this.parse(num);

Decimal.prototype.isNaN = function () {
return this.flag === 1 /* NAN */;
return this.flag === 1 /* DecimalFlag.NAN */;
};

@@ -105,3 +107,3 @@ /**

Decimal.prototype.isInfinity = function () {
return this.flag === 2 /* INFINITY */;
return this.flag === 2 /* DecimalFlag.INFINITY */;
};

@@ -122,6 +124,6 @@ /**

var u = this;
v = exports.coerceDecimal(v);
v = (0, exports.coerceDecimal)(v);
if (u.flag || v.flag) {
// NAN is never equal to itself or any other value
if (u.flag === 1 /* NAN */ || v.flag === 1 /* NAN */) {
if (u.flag === 1 /* DecimalFlag.NAN */ || v.flag === 1 /* DecimalFlag.NAN */) {
return -1;

@@ -136,3 +138,3 @@ }

// Positive infinity after all other values
return u.flag === 2 /* INFINITY */ ? (u.sign === -1 ? -1 : 1) : v.sign === -1 ? 1 : -1;
return u.flag === 2 /* DecimalFlag.INFINITY */ ? (u.sign === -1 ? -1 : 1) : v.sign === -1 ? 1 : -1;
}

@@ -163,5 +165,5 @@ u = u.stripTrailingZeros();

// Data cannot be equal here
return -operations_1.compare(v.data, u.data, shift);
return -(0, operations_1.compare)(v.data, u.data, shift);
}
return operations_1.compare(u.data, v.data, -shift);
return (0, operations_1.compare)(u.data, v.data, -shift);
}

@@ -237,4 +239,4 @@ // Same number of radix digits.

Decimal.prototype.add = function (v) {
v = exports.coerceDecimal(v);
var r = this.handleFlags(0 /* ADDITION */, v);
v = (0, exports.coerceDecimal)(v);
var r = this.handleFlags(0 /* Op.ADDITION */, v);
if (r === undefined) {

@@ -252,4 +254,4 @@ if (this.isZero()) {

Decimal.prototype.subtract = function (v) {
v = exports.coerceDecimal(v);
var r = this.handleFlags(1 /* SUBTRACTION */, v);
v = (0, exports.coerceDecimal)(v);
var r = this.handleFlags(1 /* Op.SUBTRACTION */, v);
if (r === undefined) {

@@ -268,4 +270,4 @@ if (this.isZero()) {

var _a = parseMathContext('half-even', context), usePrecision = _a[0], scaleprec = _a[1], rounding = _a[2];
v = exports.coerceDecimal(v);
var r = this.handleFlags(2 /* MULTIPLICATION */, v);
v = (0, exports.coerceDecimal)(v);
var r = this.handleFlags(2 /* Op.MULTIPLICATION */, v);
if (r !== undefined) {

@@ -286,3 +288,3 @@ return r;

}
w.data = math_1.multiply(u.data, v.data);
w.data = (0, math_1.multiply)(u.data, v.data);
w.sign = u.sign === v.sign ? 1 : -1;

@@ -306,4 +308,4 @@ w.trim();

Decimal.prototype.divide = function (v, context) {
v = exports.coerceDecimal(v);
var r = this.handleFlags(3 /* DIVISION */, v);
v = (0, exports.coerceDecimal)(v);
var r = this.handleFlags(3 /* Op.DIVISION */, v);
if (r !== undefined) {

@@ -326,6 +328,6 @@ return r;

}
var _b = math_1.divide(u.data, v.data), q = _b[0], rem = _b[1];
var _b = (0, math_1.divide)(u.data, v.data), q = _b[0], rem = _b[1];
w = Decimal.fromRaw(sign, exp, q, 0);
w.trim();
var hasrem = rem.length && !operations_1.allzero(rem, rem.length);
var hasrem = rem.length && !(0, operations_1.allzero)(rem, rem.length);
if (hasrem) {

@@ -357,6 +359,6 @@ var lsd = w.data[0] % 10;

Decimal.prototype.divmod = function (v) {
v = exports.coerceDecimal(v);
var rq = this.handleFlags(3 /* DIVISION */, v);
v = (0, exports.coerceDecimal)(v);
var rq = this.handleFlags(3 /* Op.DIVISION */, v);
if (rq !== undefined) {
var rm = this.handleFlags(4 /* MOD */, v);
var rm = this.handleFlags(4 /* Op.MOD */, v);
return [rq, rm];

@@ -385,3 +387,3 @@ }

}
var _a = math_1.divide(u.data, v.data), qd = _a[0], rd = _a[1];
var _a = (0, math_1.divide)(u.data, v.data), qd = _a[0], rd = _a[1];
var q = new Decimal(ZERO);

@@ -400,4 +402,4 @@ q.data = qd;

Decimal.prototype.mod = function (v) {
v = exports.coerceDecimal(v);
var r = this.handleFlags(4 /* MOD */, v);
v = (0, exports.coerceDecimal)(v);
var r = this.handleFlags(4 /* Op.MOD */, v);
return r === undefined ? this.divmod(v)[1] : r;

@@ -418,3 +420,3 @@ };

var n = d[i];
r = i * 7 /* RDIGITS */;
r = i * 7 /* Constants.RDIGITS */;
while (n % 10 === 0) {

@@ -463,3 +465,3 @@ n /= 10 | 0;

var len = this.data.length;
return (len - 1) * 7 /* RDIGITS */ + operations_1.digitCount(this.data[len - 1]);
return (len - 1) * 7 /* Constants.RDIGITS */ + (0, operations_1.digitCount)(this.data[len - 1]);
};

@@ -570,3 +572,3 @@ /**

var r = this.formatString(coeff, minIntegers);
return coeff.isZero() ? r : exp === 0 ? r : r + ("E" + (exp > 0 ? '+' : '') + exp);
return coeff.isZero() ? r : exp === 0 ? r : r + "E".concat(exp > 0 ? '+' : '').concat(exp);
};

@@ -593,3 +595,3 @@ /**

var sign = exp < 0 ? { type: 'minus', value: '-' } : { type: 'plus', value: '+' };
return r.concat([{ type: 'exp', value: 'E' }, sign, { type: 'integer', value: "" + Math.abs(exp) }]);
return r.concat([{ type: 'exp', value: 'E' }, sign, { type: 'integer', value: "".concat(Math.abs(exp)) }]);
};

@@ -663,3 +665,3 @@ /**

var d = this.data[i];
var c = i === last ? operations_1.digitCount(d) : 7 /* RDIGITS */;
var c = i === last ? (0, operations_1.digitCount)(d) : 7 /* Constants.RDIGITS */;
// Loop over the decimal digits

@@ -710,5 +712,5 @@ for (var j = 0; j < c; j++) {

switch (this.flag) {
case 1 /* NAN */:
case 1 /* DecimalFlag.NAN */:
return 'NaN';
case 2 /* INFINITY */:
case 2 /* DecimalFlag.INFINITY */:
default:

@@ -720,5 +722,5 @@ return this.sign === 1 ? 'Infinity' : '-Infinity';

switch (this.flag) {
case 1 /* NAN */:
case 1 /* DecimalFlag.NAN */:
return [{ type: 'nan', value: 'NaN' }];
case 2 /* INFINITY */:
case 2 /* DecimalFlag.INFINITY */:
default:

@@ -763,11 +765,11 @@ var s = this.sign === 1 ? 'Infinity' : '-Infinity';

// Any operation involving a NAN returns a NAN
if (uflag === 1 /* NAN */ || vflag === 1 /* NAN */) {
if (uflag === 1 /* DecimalFlag.NAN */ || vflag === 1 /* DecimalFlag.NAN */) {
return NAN;
}
var uinf = uflag === 2 /* INFINITY */;
var vinf = vflag === 2 /* INFINITY */;
var uinf = uflag === 2 /* DecimalFlag.INFINITY */;
var vinf = vflag === 2 /* DecimalFlag.INFINITY */;
var uzero = u.isZero();
var vzero = v.isZero();
switch (op) {
case 0 /* ADDITION */:
case 0 /* Op.ADDITION */:
if (uinf && vinf) {

@@ -780,3 +782,3 @@ return u.sign === v.sign ? (u.sign === 1 ? POSITIVE_INFINITY : NEGATIVE_INFINITY) : NAN;

break;
case 1 /* SUBTRACTION */:
case 1 /* Op.SUBTRACTION */:
if (uinf && vinf) {

@@ -795,3 +797,3 @@ return u.sign === v.sign ? NAN : u.sign === 1 ? POSITIVE_INFINITY : NEGATIVE_INFINITY;

break;
case 2 /* MULTIPLICATION */:
case 2 /* Op.MULTIPLICATION */:
if (uinf) {

@@ -804,3 +806,3 @@ return vzero ? NAN : u.sign === v.sign ? POSITIVE_INFINITY : NEGATIVE_INFINITY;

break;
case 3 /* DIVISION */:
case 3 /* Op.DIVISION */:
if (uinf && vinf) {

@@ -825,3 +827,3 @@ return NAN;

break;
case 4 /* MOD */:
case 4 /* Op.MOD */:
if (uinf || vzero) {

@@ -856,4 +858,4 @@ return NAN;

// Compute the shift in terms of our radix.
var q = (shift / 7 /* RDIGITS */) | 0;
var r = shift - q * 7 /* RDIGITS */;
var q = (shift / 7 /* Constants.RDIGITS */) | 0;
var r = shift - q * 7 /* Constants.RDIGITS */;
// Expand w to hold shifted result and zero all elements.

@@ -872,3 +874,3 @@ var n = size(prec + shift);

var powlo = types_1.POWERS10[r];
var powhi = types_1.POWERS10[7 /* RDIGITS */ - r];
var powhi = types_1.POWERS10[7 /* Constants.RDIGITS */ - r];
var hi = 0;

@@ -921,3 +923,3 @@ var lo = 0;

var div = new math_1.DivMod();
var _d = div.word(shift, 7 /* RDIGITS */), q = _d[0], r = _d[1];
var _d = div.word(shift, 7 /* Constants.RDIGITS */), q = _d[0], r = _d[1];
var data = w.data.slice();

@@ -930,5 +932,5 @@ w.data.fill(0);

// q is always non-zero here, else there would be no shift
_a = div.pow10(data[q - 1], 7 /* RDIGITS */ - 1), rnd = _a[0], rest = _a[1];
_a = div.pow10(data[q - 1], 7 /* Constants.RDIGITS */ - 1), rnd = _a[0], rest = _a[1];
if (rest === 0) {
rest = operations_1.allzero(data, q - 1) === 0 ? 1 : 0;
rest = (0, operations_1.allzero)(data, q - 1) === 0 ? 1 : 0;
}

@@ -941,3 +943,3 @@ for (j = 0; j < data.length - q; j++) {

var hiprev = 0;
var ph = types_1.POWERS10[7 /* RDIGITS */ - r];
var ph = types_1.POWERS10[7 /* Constants.RDIGITS */ - r];
// q is always < data.length here; otherwise r == 0

@@ -947,3 +949,3 @@ _b = div.pow10(data[q], r), hiprev = _b[0], rest = _b[1];

if (rest === 0 && q > 0) {
rest = operations_1.allzero(data, q) === 0 ? 1 : 0;
rest = (0, operations_1.allzero)(data, q) === 0 ? 1 : 0;
}

@@ -995,3 +997,3 @@ for (j = 0, i = q + 1; i < data.length; i++, j++) {

Decimal.prototype.trim = function () {
math_1.trimLeadingZeros(this.data);
(0, math_1.trimLeadingZeros)(this.data);
return this;

@@ -1009,3 +1011,3 @@ };

s = d[i] + k;
k = s === 10000000 /* RADIX */ ? 1 : 0;
k = s === 10000000 /* Constants.RADIX */ ? 1 : 0;
d[i] = k ? 0 : s;

@@ -1077,3 +1079,3 @@ }

if (u.sign === vsign) {
w.data = math_1.add(m.data, n.data);
w.data = (0, math_1.add)(m.data, n.data);
w.sign = vsign;

@@ -1095,3 +1097,3 @@ }

}
w.data = math_1.subtract(m.data, n.data);
w.data = (0, math_1.subtract)(m.data, n.data);
w.sign = (swap & 1) === 1 ? vsign : m.sign;

@@ -1107,7 +1109,7 @@ }

if (isNaN(arg)) {
this.flag = 1 /* NAN */;
this.flag = 1 /* DecimalFlag.NAN */;
return;
}
if (!isFinite(arg)) {
this.flag = 2 /* INFINITY */;
this.flag = 2 /* DecimalFlag.INFINITY */;
this.sign = arg === Infinity ? 1 : -1;

@@ -1134,7 +1136,7 @@ return;

if (NAN_VALUES.has(str)) {
this.flag = 1 /* NAN */;
this.flag = 1 /* DecimalFlag.NAN */;
return;
}
if (POS_INFINITY.has(str)) {
this.flag = 2 /* INFINITY */;
this.flag = 2 /* DecimalFlag.INFINITY */;
this.sign = 1;

@@ -1144,3 +1146,3 @@ return;

if (NEG_INFINITY.has(str)) {
this.flag = 2 /* INFINITY */;
this.flag = 2 /* DecimalFlag.INFINITY */;
this.sign = -1;

@@ -1169,6 +1171,6 @@ return;

switch (code) {
case 69 /* ELOWER */:
case 101 /* EUPPER */:
if (flags & 4 /* EXP */) {
return "Extra exponent character at " + i;
case 69 /* Chars.ELOWER */:
case 101 /* Chars.EUPPER */:
if (flags & 4 /* ParseFlags.EXP */) {
return "Extra exponent character at ".concat(i);
}

@@ -1183,4 +1185,4 @@ if (data.length > 0) {

// Indicate we have an exponent, and clear the sign flag.
flags |= 4 /* EXP */;
flags &= ~1 /* SIGN */;
flags |= 4 /* ParseFlags.EXP */;
flags &= ~1 /* ParseFlags.SIGN */;
// Copy the parsed number to the exponent and reset the digit count.

@@ -1193,34 +1195,34 @@ dig = 0;

break;
case 45 /* MINUS */:
case 43 /* PLUS */:
case 45 /* Chars.MINUS */:
case 43 /* Chars.PLUS */:
if (dig === 0) {
return 'Found a bare sign symbol';
}
if (flags & 1 /* SIGN */) {
return "Duplicate sign character at " + i;
if (flags & 1 /* ParseFlags.SIGN */) {
return "Duplicate sign character at ".concat(i);
}
sign = code === 45 /* MINUS */ ? -1 : 1;
flags |= 1 /* SIGN */;
sign = code === 45 /* Chars.MINUS */ ? -1 : 1;
flags |= 1 /* ParseFlags.SIGN */;
break;
case 46 /* DOT */:
if (flags & 2 /* POINT */) {
return "Extra radix point seen at " + i;
case 46 /* Chars.DOT */:
if (flags & 2 /* ParseFlags.POINT */) {
return "Extra radix point seen at ".concat(i);
}
flags |= 2 /* POINT */;
flags |= 2 /* ParseFlags.POINT */;
exp -= dig;
break;
case 48 /* DIGIT0 */:
case 49 /* DIGIT1 */:
case 50 /* DIGIT2 */:
case 51 /* DIGIT3 */:
case 52 /* DIGIT4 */:
case 53 /* DIGIT5 */:
case 54 /* DIGIT6 */:
case 55 /* DIGIT7 */:
case 56 /* DIGIT8 */:
case 57 /* DIGIT9 */:
n += (code - 48 /* DIGIT0 */) * types_1.POWERS10[z];
case 48 /* Chars.DIGIT0 */:
case 49 /* Chars.DIGIT1 */:
case 50 /* Chars.DIGIT2 */:
case 51 /* Chars.DIGIT3 */:
case 52 /* Chars.DIGIT4 */:
case 53 /* Chars.DIGIT5 */:
case 54 /* Chars.DIGIT6 */:
case 55 /* Chars.DIGIT7 */:
case 56 /* Chars.DIGIT8 */:
case 57 /* Chars.DIGIT9 */:
n += (code - 48 /* Chars.DIGIT0 */) * types_1.POWERS10[z];
z++;
dig++;
if (z === 7 /* RDIGITS */) {
if (z === 7 /* Constants.RDIGITS */) {
data.push(n);

@@ -1232,3 +1234,3 @@ n = 0;

default:
return "Unexpected character at " + i + ": " + str[i];
return "Unexpected character at ".concat(i, ": ").concat(str[i]);
}

@@ -1235,0 +1237,0 @@ i--;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PartsDecimalFormatter = exports.StringDecimalFormatter = void 0;
/**

@@ -4,0 +5,0 @@ * Formats a decimal into a string.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.divword = exports.divpow10 = exports.DivMod = exports.trimLeadingZeros = exports.divide = exports.multiplyword = exports.multiply = exports.subtract = exports.add = void 0;
var types_1 = require("./types");

@@ -9,3 +10,3 @@ /**

*/
exports.add = function (u, v) {
var add = function (u, v) {
var vlen = v.length;

@@ -22,5 +23,5 @@ var n = u.length;

var z = u[j] + vj + k;
w[j] = z % 10000000 /* RADIX */;
w[j] = z % 10000000 /* Constants.RADIX */;
// .. k is being set to 1 or 0, to carry
k = (z / 10000000 /* RADIX */) | 0;
k = (z / 10000000 /* Constants.RADIX */) | 0;
// A3. Loop on j

@@ -34,2 +35,3 @@ j++;

};
exports.add = add;
/**

@@ -40,3 +42,3 @@ * Knuth TAoCP 4.3.1 Algorithm S

*/
exports.subtract = function (u, v) {
var subtract = function (u, v) {
var m = u.length;

@@ -51,3 +53,3 @@ var n = v.length;

var z = u[j] - v[j] - k;
w[j] = z < 0 ? z + 10000000 /* RADIX */ : z;
w[j] = z < 0 ? z + 10000000 /* Constants.RADIX */ : z;
// k is set to 1 or 0, indicating a borrow

@@ -61,3 +63,3 @@ k = z < 0 ? 1 : 0;

var z = u[j] - k;
w[j] = z < 0 ? z + 10000000 /* RADIX */ : z;
w[j] = z < 0 ? z + 10000000 /* Constants.RADIX */ : z;
k = z < 0 ? 1 : 0;

@@ -73,2 +75,3 @@ j++;

};
exports.subtract = subtract;
/**

@@ -78,3 +81,3 @@ * Knuth TAoCP 4.3.1 Algorithm M

*/
exports.multiply = function (u, v) {
var multiply = function (u, v) {
var m = u.length;

@@ -96,4 +99,4 @@ var n = v.length;

var p = k + w[i + j] + u[i] * v[j];
k = (p / 10000000 /* RADIX */) | 0;
w[i + j] = p - k * 10000000 /* RADIX */;
k = (p / 10000000 /* Constants.RADIX */) | 0;
w[i + j] = p - k * 10000000 /* Constants.RADIX */;
// M5. Loop on i

@@ -109,2 +112,3 @@ i++;

};
exports.multiply = multiply;
/**

@@ -114,3 +118,3 @@ * Multiplication of a nonnegative integer u by a single word v, returning the product w.

*/
exports.multiplyword = function (w, u, n, v) {
var multiplyword = function (w, u, n, v) {
var i = 0;

@@ -120,4 +124,4 @@ var k = 0;

var p = k + u[i] * v;
k = (p / 10000000 /* RADIX */) | 0;
w[i] = p - k * 10000000 /* RADIX */;
k = (p / 10000000 /* Constants.RADIX */) | 0;
w[i] = p - k * 10000000 /* Constants.RADIX */;
}

@@ -128,2 +132,3 @@ if (k > 0) {

};
exports.multiplyword = multiplyword;
/**

@@ -133,3 +138,3 @@ * Knuth TAoCP 4.3.1 Algorithm D

*/
exports.divide = function (uc, vc) {
var divide = function (uc, vc) {
var n = vc.length;

@@ -142,3 +147,3 @@ var m = uc.length - n;

if (nplusm < n) {
throw new Error("n + m must be >= n, got " + m);
throw new Error("n + m must be >= n, got ".concat(m));
}

@@ -155,6 +160,6 @@ // Storage for copy of u which is modified in place, and v which needs an

// D1. Normalize
var d = (10000000 /* RADIX */ / (v[n - 1] + 1)) | 0;
var d = (10000000 /* Constants.RADIX */ / (v[n - 1] + 1)) | 0;
if (d !== 1) {
exports.multiplyword(u, uc, nplusm, d);
exports.multiplyword(v, vc, n, d);
(0, exports.multiplyword)(u, uc, nplusm, d);
(0, exports.multiplyword)(v, vc, n, d);
}

@@ -168,3 +173,3 @@ var k = 0;

// D3. Calculate q̂ and r̂.
p = u[j + n - 1] + u[j + n] * 10000000 /* RADIX */;
p = u[j + n - 1] + u[j + n] * 10000000 /* Constants.RADIX */;
var qhat = (p / v[n - 1]) | 0;

@@ -174,6 +179,6 @@ var rhat = p - qhat * v[n - 1];

// D3. Test if q̂ = radix ...
if (qhat < 10000000 /* RADIX */) {
if (qhat < 10000000 /* Constants.RADIX */) {
var z = qhat * v[n - 2];
hi = (z / 10000000 /* RADIX */) | 0;
lo = z - hi * 10000000 /* RADIX */;
hi = (z / 10000000 /* Constants.RADIX */) | 0;
lo = z - hi * 10000000 /* Constants.RADIX */;
if (hi <= rhat) {

@@ -188,3 +193,3 @@ if (hi !== rhat || lo <= u[j + n - 2]) {

rhat += v[n - 1];
if (rhat >= 10000000 /* RADIX */) {
if (rhat >= 10000000 /* Constants.RADIX */) {
break;

@@ -199,8 +204,8 @@ }

p = qhat * v[i] + k;
hi = (p / 10000000 /* RADIX */) | 0;
lo = p - hi * 10000000 /* RADIX */;
hi = (p / 10000000 /* Constants.RADIX */) | 0;
lo = p - hi * 10000000 /* Constants.RADIX */;
// Subtract and determine carry.
var x = u[i + j] - lo;
k = x < 0 ? 1 : 0;
u[i + j] = k ? x + 10000000 /* RADIX */ : x;
u[i + j] = k ? x + 10000000 /* Constants.RADIX */ : x;
k += hi;

@@ -224,3 +229,3 @@ }

for (var i = n - 1; i >= 0; i--) {
p = u[i] + k * 10000000 /* RADIX */;
p = u[i] + k * 10000000 /* Constants.RADIX */;
r[i] = (p / d) | 0;

@@ -231,2 +236,3 @@ k = p - r[i] * d;

};
exports.divide = divide;
/**

@@ -243,3 +249,3 @@ * Knuth TAoCP 4.3.1 Exercise 16

for (var i = n - 1; i >= 0; i--) {
var p = u[i] + r * 10000000 /* RADIX */;
var p = u[i] + r * 10000000 /* Constants.RADIX */;
q[i] = (p / v) | 0;

@@ -259,4 +265,4 @@ r = p - q[i] * v;

s = u[i + j] + (v[i] + k);
k = s >= 10000000 /* RADIX */ ? 1 : 0;
u[i + j] = k ? s - 10000000 /* RADIX */ : s;
k = s >= 10000000 /* Constants.RADIX */ ? 1 : 0;
u[i + j] = k ? s - 10000000 /* Constants.RADIX */ : s;
i++;

@@ -266,4 +272,4 @@ }

s = u[i + j] + k;
k = s === 10000000 /* RADIX */ ? 1 : /* istanbul ignore next */ 0;
u[i + j] = k === 1 ? s - 10000000 /* RADIX */ : /* istanbul ignore next */ s;
k = s === 10000000 /* Constants.RADIX */ ? 1 : /* istanbul ignore next */ 0;
u[i + j] = k === 1 ? s - 10000000 /* Constants.RADIX */ : /* istanbul ignore next */ s;
i++;

@@ -277,3 +283,3 @@ }

*/
exports.trimLeadingZeros = function (data) {
var trimLeadingZeros = function (data) {
var i = data.length - 1;

@@ -285,2 +291,3 @@ while (i > 0 && data[i] === 0) {

};
exports.trimLeadingZeros = trimLeadingZeros;
/**

@@ -295,3 +302,3 @@ * Reusable quotient and remainder for repeated divmod operations.

DivMod.prototype.pow10 = function (n, exp) {
return exports.divpow10(this.s, n, exp);
return (0, exports.divpow10)(this.s, n, exp);
};

@@ -302,3 +309,3 @@ /**

DivMod.prototype.word = function (n, w) {
return exports.divword(this.s, n, w);
return (0, exports.divword)(this.s, n, w);
};

@@ -311,3 +318,3 @@ return DivMod;

*/
exports.divpow10 = function (d, n, exp) {
var divpow10 = function (d, n, exp) {
var p = types_1.POWERS10[exp];

@@ -318,6 +325,7 @@ d[0] = (n / p) | 0;

};
exports.divpow10 = divpow10;
/**
* Divide and modulus by w. Store result in d = [quotient, remainder].
*/
exports.divword = function (_d, n, div) {
var divword = function (_d, n, div) {
var q = (n / div) | 0;

@@ -327,2 +335,3 @@ var r = n - q * div;

};
exports.divword = divword;
//# sourceMappingURL=math.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.digitCount = exports.allzero = exports.compare = void 0;
var math_1 = require("./math");
var types_1 = require("./types");
var cmp = function (a, b) { return (a < b ? -1 : a === b ? 0 : 1); };
exports.compare = function (a, b, shift) {
var compare = function (a, b, shift) {
var _a, _b;

@@ -11,3 +12,3 @@ var div = new math_1.DivMod();

var m = b.length;
var _c = div.word(shift, 7 /* RDIGITS */), q = _c[0], r = _c[1];
var _c = div.word(shift, 7 /* Constants.RDIGITS */), q = _c[0], r = _c[1];
if (r === 0) {

@@ -29,3 +30,3 @@ while (--m >= 0) {

--n;
_a = div.pow10(b[m--], 7 /* RDIGITS */ - r), hi = _a[0], loprev = _a[1];
_a = div.pow10(b[m--], 7 /* Constants.RDIGITS */ - r), hi = _a[0], loprev = _a[1];
if (hi !== 0) {

@@ -40,3 +41,3 @@ c = cmp(a[n], hi);

for (; m >= 0; m--, n--) {
_b = div.pow10(b[m], 7 /* RDIGITS */ - r), hi = _b[0], lo = _b[1];
_b = div.pow10(b[m], 7 /* Constants.RDIGITS */ - r), hi = _b[0], lo = _b[1];
x = ph * loprev + hi;

@@ -55,5 +56,6 @@ c = cmp(a[n], x);

}
return Number(!exports.allzero(a, q));
return Number(!(0, exports.allzero)(a, q));
};
exports.allzero = function (data, len) {
exports.compare = compare;
var allzero = function (data, len) {
if (len <= data.length) {

@@ -68,17 +70,19 @@ while (--len >= 0) {

};
exports.allzero = allzero;
/**
* Returns the number of digits in w, where w < RADIX.
*/
exports.digitCount = function (w) {
if (w < 10000 /* P4 */) {
if (w < 100 /* P2 */) {
return w < 10 /* P1 */ ? 1 : 2;
var digitCount = function (w) {
if (w < 10000 /* Constants.P4 */) {
if (w < 100 /* Constants.P2 */) {
return w < 10 /* Constants.P1 */ ? 1 : 2;
}
return w < 1000 /* P3 */ ? 3 : 4;
return w < 1000 /* Constants.P3 */ ? 3 : 4;
}
if (w < 1000000 /* P6 */) {
return w < 100000 /* P5 */ ? 5 : 6;
if (w < 1000000 /* Constants.P6 */) {
return w < 100000 /* Constants.P5 */ ? 5 : 6;
}
return w < 10000000 /* P7 */ ? 7 : 8;
return w < 10000000 /* Constants.P7 */ ? 7 : 8;
};
exports.digitCount = digitCount;
//# sourceMappingURL=operations.js.map

@@ -8,3 +8,3 @@ import { Decimal, DecimalArg } from './decimal';

*/
export declare type RationalArg = Rational | Decimal | number | string;
export type RationalArg = Rational | Decimal | number | string;
/**

@@ -11,0 +11,0 @@ * Arbitrary precision rational type.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RationalConstants = exports.Rational = void 0;
var decimal_1 = require("./decimal");

@@ -82,3 +83,3 @@ var coerceDecimal = function (n) {

Rational.prototype.toString = function () {
return this.numer.toString() + " / " + this.denom.toString();
return "".concat(this.numer.toString(), " / ").concat(this.denom.toString());
};

@@ -85,0 +86,0 @@ Rational.prototype._parse = function (raw) {

@@ -16,3 +16,3 @@ /**

*/
export declare type RoundingModeType = 'up' | 'down' | 'ceiling' | 'floor' | 'half-up' | 'half-down' | 'half-even';
export type RoundingModeType = 'up' | 'down' | 'ceiling' | 'floor' | 'half-up' | 'half-down' | 'half-even';
/**

@@ -19,0 +19,0 @@ * Sets the scale or precision, and the rounding mode for a math operation.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.POWERS10 = void 0;
exports.POWERS10 = [
1 /* P0 */,
10 /* P1 */,
100 /* P2 */,
1000 /* P3 */,
10000 /* P4 */,
100000 /* P5 */,
1000000 /* P6 */,
10000000 /* P7 */,
100000000 /* P8 */,
1 /* Constants.P0 */,
10 /* Constants.P1 */,
100 /* Constants.P2 */,
1000 /* Constants.P3 */,
10000 /* Constants.P4 */,
100000 /* Constants.P5 */,
1000000 /* Constants.P6 */,
10000000 /* Constants.P7 */,
100000000 /* Constants.P8 */,
];
//# sourceMappingURL=types.js.map
{
"name": "@phensley/decimal",
"version": "1.2.13",
"version": "1.2.14",
"description": "Arbitrary precision decimal math",

@@ -39,3 +39,3 @@ "main": "lib/index.js",

"dependencies": {
"tslib": "^1.13.0"
"tslib": "^2.3.1"
},

@@ -46,15 +46,15 @@ "devDependencies": {

"@types/node": "^14.0.1",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"@typescript-eslint/eslint-plugin": "5.55.0",
"@typescript-eslint/parser": "5.55.0",
"beautify-benchmark": "^0.2.4",
"benchmark": "^2.1.4",
"chalk": "^4.0.0",
"eslint": "^7.0.0",
"eslint": "^8.32.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"jest": "^26.0.1",
"jest": "25.5.4",
"prettier": "^2.0.5",
"rimraf": "^3.0.2",
"ts-jest": "^25.5.1",
"typescript": "~3.8.3"
"ts-jest": "25.5.1",
"typescript": "4.9.4"
},

@@ -74,3 +74,3 @@ "jest": {

},
"gitHead": "1649a9047668bc4519d33526f50174ba3f2e2d32"
"gitHead": "bea64f8ab05fb48af97cfa88b1293e0b17d2ed0d"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc