Consider adding support for integer roots, as it can be done somewhat faster than pow in general (and may be more accurate). This quick implementation is about 25% faster:
Decimal.prototype.nthRoot = function (value) {
if (this.mantissa === 0) return ME_NN(0, 0);
if (value > 307) return this.pow(1 / value);
if (value === 0) return ME_NN(1, 0);
const newExp = Math.floor(this.exponent / value);
const excessExp = this.exponent - value * newExp;
return ME(Math.pow(powerOf10(excessExp) * this.mantissa, 1 / value), newExp);
};
(It doesn't take the sign of the base into account, though)
Consider adding support for integer roots, as it can be done somewhat faster than pow in general (and may be more accurate). This quick implementation is about 25% faster:
(It doesn't take the sign of the base into account, though)