@phensley/decimal
Advanced tools
Comparing version 0.25.4 to 0.25.5
@@ -263,21 +263,9 @@ import { add, divide, multiply, subtract, trimLeadingZeros, DivMod } from './math'; | ||
var _a = parseMathContext('half-even', context), usePrecision = _a[0], scaleprec = _a[1], rounding = _a[2]; | ||
var w; | ||
var u = this; | ||
if (!usePrecision) { | ||
// Shift the numerator to ensure the result has the desired scale. | ||
var sh = scaleprec + v.scale(); | ||
if (sh > 0) { | ||
u = u.shiftleft(sh); | ||
u.exp -= sh; | ||
} | ||
} | ||
var w = new Decimal(ZERO); | ||
// Shift in extra digits for rounding. | ||
var shift = 2; | ||
// In precision mode, ensure shift takes into account target precision | ||
if (usePrecision) { | ||
shift += (v.precision() - u.precision()) + scaleprec; | ||
} | ||
// Calculate the exponent on the result | ||
var sign = u.sign === v.sign ? 1 : -1; | ||
var shift = usePrecision | ||
? (v.precision() - u.precision()) + scaleprec + 2 | ||
: v.precision() + u.precision() + scaleprec + 2; | ||
var exp = (u.exp - v.exp) - shift; | ||
// Shift numerator or denominator | ||
if (shift > 0) { | ||
@@ -289,7 +277,4 @@ u = u.shiftleft(shift); | ||
} | ||
// Perform the division. | ||
var _b = divide(u.data, v.data, false), q = _b[0], rem = _b[1]; | ||
w.data = q; | ||
w.sign = u.sign === v.sign ? 1 : -1; | ||
w.exp = exp; | ||
var _b = divide(u.data, v.data, true), q = _b[0], rem = _b[1]; | ||
w = Decimal.fromRaw(sign, exp, q, 0); | ||
w.trim(); | ||
@@ -914,2 +899,3 @@ var hasrem = rem.length && rem[rem.length - 1] !== 0; | ||
this.exp = scale === 0 ? 0 : -scale; | ||
this.trim(); | ||
}; | ||
@@ -916,0 +902,0 @@ Decimal.prototype._stripTrailingZeros = function () { |
@@ -265,21 +265,9 @@ "use strict"; | ||
var _a = parseMathContext('half-even', context), usePrecision = _a[0], scaleprec = _a[1], rounding = _a[2]; | ||
var w; | ||
var u = this; | ||
if (!usePrecision) { | ||
// Shift the numerator to ensure the result has the desired scale. | ||
var sh = scaleprec + v.scale(); | ||
if (sh > 0) { | ||
u = u.shiftleft(sh); | ||
u.exp -= sh; | ||
} | ||
} | ||
var w = new Decimal(ZERO); | ||
// Shift in extra digits for rounding. | ||
var shift = 2; | ||
// In precision mode, ensure shift takes into account target precision | ||
if (usePrecision) { | ||
shift += (v.precision() - u.precision()) + scaleprec; | ||
} | ||
// Calculate the exponent on the result | ||
var sign = u.sign === v.sign ? 1 : -1; | ||
var shift = usePrecision | ||
? (v.precision() - u.precision()) + scaleprec + 2 | ||
: v.precision() + u.precision() + scaleprec + 2; | ||
var exp = (u.exp - v.exp) - shift; | ||
// Shift numerator or denominator | ||
if (shift > 0) { | ||
@@ -291,7 +279,4 @@ u = u.shiftleft(shift); | ||
} | ||
// Perform the division. | ||
var _b = math_1.divide(u.data, v.data, false), q = _b[0], rem = _b[1]; | ||
w.data = q; | ||
w.sign = u.sign === v.sign ? 1 : -1; | ||
w.exp = exp; | ||
var _b = math_1.divide(u.data, v.data, true), q = _b[0], rem = _b[1]; | ||
w = Decimal.fromRaw(sign, exp, q, 0); | ||
w.trim(); | ||
@@ -916,2 +901,3 @@ var hasrem = rem.length && rem[rem.length - 1] !== 0; | ||
this.exp = scale === 0 ? 0 : -scale; | ||
this.trim(); | ||
}; | ||
@@ -918,0 +904,0 @@ Decimal.prototype._stripTrailingZeros = function () { |
{ | ||
"name": "@phensley/decimal", | ||
"version": "0.25.4", | ||
"version": "0.25.5", | ||
"description": "Arbitrary precision decimal math", | ||
@@ -65,3 +65,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "52cf835e9a4ddc35c4dc7eeeb9e9dc5cb57c5158" | ||
"gitHead": "4066c30580c5d4dffd9261c1a989aff283a899ea" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
249814
4265