js-big-decimal
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -5,3 +5,3 @@ import { RoundingModes as Modes } from './roundingModes'; | ||
static RoundingModes: typeof Modes; | ||
private static validate(number); | ||
private static validate; | ||
constructor(number?: number | string); | ||
@@ -8,0 +8,0 @@ getValue(): string; |
@@ -49,7 +49,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||
/******/ } | ||
@@ -60,5 +56,24 @@ /******/ }; | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
@@ -81,3 +96,3 @@ /******/ __webpack_require__.n = function(module) { | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 7); | ||
/******/ return __webpack_require__(__webpack_require__.s = 3); | ||
/******/ }) | ||
@@ -94,2 +109,3 @@ /************************************************************************/ | ||
function add(number1, number2) { | ||
var _a; | ||
if (number2 === void 0) { number2 = "0"; } | ||
@@ -130,3 +146,2 @@ var neg = 0, ind = -1, neg_len; | ||
} | ||
var _a; | ||
} | ||
@@ -181,2 +196,3 @@ exports.add = add; | ||
function addCore(number1, number2) { | ||
var _a; | ||
_a = pad(number1, number2), number1 = _a[0], number2 = _a[1]; | ||
@@ -194,3 +210,2 @@ var sum = '', carry = 0; | ||
return carry ? (carry.toString() + sum) : sum; | ||
var _a; | ||
} | ||
@@ -206,51 +221,3 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var RoundingModes; | ||
(function (RoundingModes) { | ||
/** | ||
* Rounding mode to round towards positive infinity. | ||
*/ | ||
RoundingModes[RoundingModes["CEILING"] = 0] = "CEILING"; | ||
/** | ||
* Rounding mode to round towards zero. | ||
*/ | ||
RoundingModes[RoundingModes["DOWN"] = 1] = "DOWN"; | ||
/** | ||
* Rounding mode to round towards negative infinity. | ||
*/ | ||
RoundingModes[RoundingModes["FLOOR"] = 2] = "FLOOR"; | ||
/** | ||
* Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case round down. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_DOWN"] = 3] = "HALF_DOWN"; | ||
/** | ||
* Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case, round towards the even neighbor. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_EVEN"] = 4] = "HALF_EVEN"; | ||
/** | ||
* Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case round up. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_UP"] = 5] = "HALF_UP"; | ||
/** | ||
* Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary. | ||
* UNIMPLEMENTED | ||
*/ | ||
RoundingModes[RoundingModes["UNNECESSARY"] = 6] = "UNNECESSARY"; | ||
/** | ||
* Rounding mode to round away from zero. | ||
*/ | ||
RoundingModes[RoundingModes["UP"] = 7] = "UP"; | ||
})(RoundingModes = exports.RoundingModes || (exports.RoundingModes = {})); | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var roundingModes_1 = __webpack_require__(1); | ||
var roundingModes_1 = __webpack_require__(2); | ||
/** | ||
@@ -364,3 +331,3 @@ * | ||
/***/ }), | ||
/* 3 */ | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -371,24 +338,45 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
function subtract(number1, number2) { | ||
number1 = number1.toString(); | ||
number2 = number2.toString(); | ||
number2 = negate(number2); | ||
return add_1.add(number1, number2); | ||
} | ||
exports.subtract = subtract; | ||
function negate(number) { | ||
if (number[0] == '-') { | ||
number = number.substr(1); | ||
} | ||
else { | ||
number = '-' + number; | ||
} | ||
return number; | ||
} | ||
exports.negate = negate; | ||
var RoundingModes; | ||
(function (RoundingModes) { | ||
/** | ||
* Rounding mode to round towards positive infinity. | ||
*/ | ||
RoundingModes[RoundingModes["CEILING"] = 0] = "CEILING"; | ||
/** | ||
* Rounding mode to round towards zero. | ||
*/ | ||
RoundingModes[RoundingModes["DOWN"] = 1] = "DOWN"; | ||
/** | ||
* Rounding mode to round towards negative infinity. | ||
*/ | ||
RoundingModes[RoundingModes["FLOOR"] = 2] = "FLOOR"; | ||
/** | ||
* Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case round down. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_DOWN"] = 3] = "HALF_DOWN"; | ||
/** | ||
* Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case, round towards the even neighbor. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_EVEN"] = 4] = "HALF_EVEN"; | ||
/** | ||
* Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case round up. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_UP"] = 5] = "HALF_UP"; | ||
/** | ||
* Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary. | ||
* UNIMPLEMENTED | ||
*/ | ||
RoundingModes[RoundingModes["UNNECESSARY"] = 6] = "UNNECESSARY"; | ||
/** | ||
* Rounding mode to round away from zero. | ||
*/ | ||
RoundingModes[RoundingModes["UP"] = 7] = "UP"; | ||
})(RoundingModes = exports.RoundingModes || (exports.RoundingModes = {})); | ||
/***/ }), | ||
/* 4 */ | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -398,261 +386,9 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
function compareTo(number1, number2) { | ||
var negative = false; | ||
if (number1[0] == '-' && number2[0] != "-") { | ||
return -1; | ||
} | ||
else if (number1[0] != '-' && number2[0] == '-') { | ||
return 1; | ||
} | ||
else if (number1[0] == '-' && number2[0] == '-') { | ||
number1 = number1.substr(1); | ||
number2 = number2.substr(1); | ||
negative = true; | ||
} | ||
_a = add_1.pad(number1, number2), number1 = _a[0], number2 = _a[1]; | ||
if (number1.localeCompare(number2) == 0) { | ||
return 0; | ||
} | ||
for (var i = 0; i < number1.length; i++) { | ||
if (number1[i] == number2[i]) { | ||
continue; | ||
} | ||
else if (number1[i] > number2[i]) { | ||
if (negative) { | ||
return -1; | ||
} | ||
else { | ||
return 1; | ||
} | ||
} | ||
else { | ||
if (negative) { | ||
return 1; | ||
} | ||
else { | ||
return -1; | ||
} | ||
} | ||
} | ||
return 0; | ||
var _a; | ||
} | ||
exports.compareTo = compareTo; | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
var round_1 = __webpack_require__(2); | ||
function divide(dividend, divisor, precission) { | ||
if (precission === void 0) { precission = 8; } | ||
if (divisor == 0) { | ||
throw new Error('Cannot divide by 0'); | ||
} | ||
dividend = dividend.toString(); | ||
divisor = divisor.toString(); | ||
if (dividend == 0) | ||
return '0'; | ||
var neg = 0; | ||
if (divisor[0] == '-') { | ||
divisor = divisor.substring(1); | ||
neg++; | ||
} | ||
if (dividend[0] == '-') { | ||
dividend = dividend.substring(1); | ||
neg++; | ||
} | ||
var pt_dvsr = divisor.indexOf('.') > 0 ? divisor.length - divisor.indexOf('.') - 1 : -1; | ||
divisor = add_1.trim(divisor.replace('.', '')); | ||
if (pt_dvsr >= 0) { | ||
var pt_dvnd = dividend.indexOf('.') > 0 ? dividend.length - dividend.indexOf('.') - 1 : -1; | ||
if (pt_dvnd == -1) { | ||
dividend = add_1.trim(dividend + (new Array(pt_dvsr + 1)).join('0')); | ||
} | ||
else { | ||
if (pt_dvsr > pt_dvnd) { | ||
dividend = dividend.replace('.', ''); | ||
dividend = add_1.trim(dividend + (new Array(pt_dvsr - pt_dvnd + 1)).join('0')); | ||
} | ||
else if (pt_dvsr < pt_dvnd) { | ||
dividend = dividend.replace('.', ''); | ||
var loc = dividend.length - pt_dvsr + pt_dvsr; | ||
dividend = add_1.trim(dividend.substring(0, loc) + '.' + dividend.substring(loc)); | ||
} | ||
else if (pt_dvsr == pt_dvnd) { | ||
dividend = add_1.trim(dividend.replace('.', '')); | ||
} | ||
} | ||
} | ||
var prec = 0, dl = divisor.length, rem = '0', quotent = ''; | ||
var dvnd = (dividend.indexOf('.') > -1 && dividend.indexOf('.') < dl) ? dividend.substring(0, dl + 1) : dividend.substring(0, dl); | ||
dividend = (dividend.indexOf('.') > -1 && dividend.indexOf('.') < dl) ? dividend.substring(dl + 1) : dividend.substring(dl); | ||
if (dvnd.indexOf('.') > -1) { | ||
var shift = dvnd.length - dvnd.indexOf('.') - 1; | ||
dvnd = dvnd.replace('.', ''); | ||
if (dl > dvnd.length) { | ||
shift += dl - dvnd.length; | ||
dvnd = dvnd + (new Array(dl - dvnd.length + 1)).join('0'); | ||
} | ||
prec = shift; | ||
quotent = '0.' + (new Array(shift)).join('0'); | ||
} | ||
precission = precission + 2; | ||
while (prec <= precission) { | ||
var qt = 0; | ||
while (parseInt(dvnd) >= parseInt(divisor)) { | ||
dvnd = add_1.add(dvnd, '-' + divisor); | ||
qt++; | ||
} | ||
quotent += qt; | ||
if (!dividend) { | ||
if (!prec) | ||
quotent += '.'; | ||
prec++; | ||
dvnd = dvnd + '0'; | ||
} | ||
else { | ||
if (dividend[0] == '.') { | ||
quotent += '.'; | ||
prec++; | ||
dividend = dividend.substring(1); | ||
} | ||
dvnd = dvnd + dividend.substring(0, 1); | ||
dividend = dividend.substring(1); | ||
} | ||
} | ||
return ((neg == 1) ? '-' : '') + add_1.trim(round_1.roundOff(quotent, precission - 2)); | ||
} | ||
exports.divide = divide; | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function multiply(number1, number2) { | ||
number1 = number1.toString(); | ||
number2 = number2.toString(); | ||
/*Filter numbers*/ | ||
var negative = 0; | ||
if (number1[0] == '-') { | ||
negative++; | ||
number1 = number1.substr(1); | ||
} | ||
if (number2[0] == '-') { | ||
negative++; | ||
number2 = number2.substr(1); | ||
} | ||
number1 = trailZero(number1); | ||
number2 = trailZero(number2); | ||
var decimalLength1 = 0; | ||
var decimalLength2 = 0; | ||
if (number1.indexOf('.') != -1) { | ||
decimalLength1 = number1.length - number1.indexOf('.') - 1; | ||
} | ||
if (number2.indexOf('.') != -1) { | ||
decimalLength2 = number2.length - number2.indexOf('.') - 1; | ||
} | ||
var decimalLength = decimalLength1 + decimalLength2; | ||
number1 = trailZero(number1.replace('.', '')); | ||
number2 = trailZero(number2.replace('.', '')); | ||
if (number1.length < number2.length) { | ||
var temp = number1; | ||
number1 = number2; | ||
number2 = temp; | ||
} | ||
if (number2 == '0') { | ||
return '0'; | ||
} | ||
/* | ||
* Core multiplication | ||
*/ | ||
var length = number2.length; | ||
var carry = 0; | ||
var positionVector = []; | ||
var currentPosition = length - 1; | ||
var result = ""; | ||
for (var i = 0; i < length; i++) { | ||
positionVector[i] = number1.length - 1; | ||
} | ||
for (var i = 0; i < 2 * number1.length; i++) { | ||
var sum = 0; | ||
for (var j = number2.length - 1; j >= currentPosition && j >= 0; j--) { | ||
if (positionVector[j] > -1 && positionVector[j] < number1.length) { | ||
sum += parseInt(number1[positionVector[j]--]) * parseInt(number2[j]); | ||
} | ||
} | ||
sum += carry; | ||
carry = Math.floor(sum / 10); | ||
result = sum % 10 + result; | ||
currentPosition--; | ||
} | ||
/* | ||
* Formatting result | ||
*/ | ||
result = trailZero(adjustDecimal(result, decimalLength)); | ||
if (negative == 1) { | ||
result = '-' + result; | ||
} | ||
return result; | ||
} | ||
exports.multiply = multiply; | ||
/* | ||
* Add decimal point | ||
*/ | ||
function adjustDecimal(number, decimal) { | ||
if (decimal == 0) | ||
return number; | ||
else { | ||
number = (decimal >= number.length) ? ((new Array(decimal - number.length + 1)).join('0') + number) : number; | ||
return number.substr(0, number.length - decimal) + '.' + number.substr(number.length - decimal, decimal); | ||
} | ||
} | ||
/* | ||
* Removes zero from front and back*/ | ||
function trailZero(number) { | ||
while (number[0] == '0') { | ||
number = number.substr(1); | ||
} | ||
if (number.indexOf('.') != -1) { | ||
while (number[number.length - 1] == '0') { | ||
number = number.substr(0, number.length - 1); | ||
} | ||
} | ||
if (number == "" || number == ".") { | ||
number = '0'; | ||
} | ||
else if (number[number.length - 1] == '.') { | ||
number = number.substr(0, number.length - 1); | ||
} | ||
if (number[0] == '.') { | ||
number = '0' + number; | ||
} | ||
return number; | ||
} | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var add_1 = __webpack_require__(0); | ||
var round_1 = __webpack_require__(2); | ||
var multiply_1 = __webpack_require__(6); | ||
var round_1 = __webpack_require__(1); | ||
var multiply_1 = __webpack_require__(4); | ||
var divide_1 = __webpack_require__(5); | ||
var compareTo_1 = __webpack_require__(4); | ||
var subtract_1 = __webpack_require__(3); | ||
var roundingModes_1 = __webpack_require__(1); | ||
var compareTo_1 = __webpack_require__(6); | ||
var subtract_1 = __webpack_require__(7); | ||
var roundingModes_1 = __webpack_require__(2); | ||
var bigDecimal = /** @class */ (function () { | ||
@@ -814,4 +550,286 @@ function bigDecimal(number) { | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function multiply(number1, number2) { | ||
number1 = number1.toString(); | ||
number2 = number2.toString(); | ||
/*Filter numbers*/ | ||
var negative = 0; | ||
if (number1[0] == '-') { | ||
negative++; | ||
number1 = number1.substr(1); | ||
} | ||
if (number2[0] == '-') { | ||
negative++; | ||
number2 = number2.substr(1); | ||
} | ||
number1 = trailZero(number1); | ||
number2 = trailZero(number2); | ||
var decimalLength1 = 0; | ||
var decimalLength2 = 0; | ||
if (number1.indexOf('.') != -1) { | ||
decimalLength1 = number1.length - number1.indexOf('.') - 1; | ||
} | ||
if (number2.indexOf('.') != -1) { | ||
decimalLength2 = number2.length - number2.indexOf('.') - 1; | ||
} | ||
var decimalLength = decimalLength1 + decimalLength2; | ||
number1 = trailZero(number1.replace('.', '')); | ||
number2 = trailZero(number2.replace('.', '')); | ||
if (number1.length < number2.length) { | ||
var temp = number1; | ||
number1 = number2; | ||
number2 = temp; | ||
} | ||
if (number2 == '0') { | ||
return '0'; | ||
} | ||
/* | ||
* Core multiplication | ||
*/ | ||
var length = number2.length; | ||
var carry = 0; | ||
var positionVector = []; | ||
var currentPosition = length - 1; | ||
var result = ""; | ||
for (var i = 0; i < length; i++) { | ||
positionVector[i] = number1.length - 1; | ||
} | ||
for (var i = 0; i < 2 * number1.length; i++) { | ||
var sum = 0; | ||
for (var j = number2.length - 1; j >= currentPosition && j >= 0; j--) { | ||
if (positionVector[j] > -1 && positionVector[j] < number1.length) { | ||
sum += parseInt(number1[positionVector[j]--]) * parseInt(number2[j]); | ||
} | ||
} | ||
sum += carry; | ||
carry = Math.floor(sum / 10); | ||
result = sum % 10 + result; | ||
currentPosition--; | ||
} | ||
/* | ||
* Formatting result | ||
*/ | ||
result = trailZero(adjustDecimal(result, decimalLength)); | ||
if (negative == 1) { | ||
result = '-' + result; | ||
} | ||
return result; | ||
} | ||
exports.multiply = multiply; | ||
/* | ||
* Add decimal point | ||
*/ | ||
function adjustDecimal(number, decimal) { | ||
if (decimal == 0) | ||
return number; | ||
else { | ||
number = (decimal >= number.length) ? ((new Array(decimal - number.length + 1)).join('0') + number) : number; | ||
return number.substr(0, number.length - decimal) + '.' + number.substr(number.length - decimal, decimal); | ||
} | ||
} | ||
/* | ||
* Removes zero from front and back*/ | ||
function trailZero(number) { | ||
while (number[0] == '0') { | ||
number = number.substr(1); | ||
} | ||
if (number.indexOf('.') != -1) { | ||
while (number[number.length - 1] == '0') { | ||
number = number.substr(0, number.length - 1); | ||
} | ||
} | ||
if (number == "" || number == ".") { | ||
number = '0'; | ||
} | ||
else if (number[number.length - 1] == '.') { | ||
number = number.substr(0, number.length - 1); | ||
} | ||
if (number[0] == '.') { | ||
number = '0' + number; | ||
} | ||
return number; | ||
} | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
var round_1 = __webpack_require__(1); | ||
function divide(dividend, divisor, precission) { | ||
if (precission === void 0) { precission = 8; } | ||
if (divisor == 0) { | ||
throw new Error('Cannot divide by 0'); | ||
} | ||
dividend = dividend.toString(); | ||
divisor = divisor.toString(); | ||
// remove trailing zeros in decimal ISSUE#18 | ||
dividend = dividend.replace(/(\.\d*?[1-9])0+$/g, "$1").replace(/\.0+$/, ""); | ||
divisor = divisor.replace(/(\.\d*?[1-9])0+$/g, "$1").replace(/\.0+$/, ""); | ||
if (dividend == 0) | ||
return '0'; | ||
var neg = 0; | ||
if (divisor[0] == '-') { | ||
divisor = divisor.substring(1); | ||
neg++; | ||
} | ||
if (dividend[0] == '-') { | ||
dividend = dividend.substring(1); | ||
neg++; | ||
} | ||
var pt_dvsr = divisor.indexOf('.') > 0 ? divisor.length - divisor.indexOf('.') - 1 : -1; | ||
divisor = add_1.trim(divisor.replace('.', '')); | ||
if (pt_dvsr >= 0) { | ||
var pt_dvnd = dividend.indexOf('.') > 0 ? dividend.length - dividend.indexOf('.') - 1 : -1; | ||
if (pt_dvnd == -1) { | ||
dividend = add_1.trim(dividend + (new Array(pt_dvsr + 1)).join('0')); | ||
} | ||
else { | ||
if (pt_dvsr > pt_dvnd) { | ||
dividend = dividend.replace('.', ''); | ||
dividend = add_1.trim(dividend + (new Array(pt_dvsr - pt_dvnd + 1)).join('0')); | ||
} | ||
else if (pt_dvsr < pt_dvnd) { | ||
dividend = dividend.replace('.', ''); | ||
var loc = dividend.length - pt_dvnd + pt_dvsr; | ||
dividend = add_1.trim(dividend.substring(0, loc) + '.' + dividend.substring(loc)); | ||
} | ||
else if (pt_dvsr == pt_dvnd) { | ||
dividend = add_1.trim(dividend.replace('.', '')); | ||
} | ||
} | ||
} | ||
var prec = 0, dl = divisor.length, rem = '0', quotent = ''; | ||
var dvnd = (dividend.indexOf('.') > -1 && dividend.indexOf('.') < dl) ? dividend.substring(0, dl + 1) : dividend.substring(0, dl); | ||
dividend = (dividend.indexOf('.') > -1 && dividend.indexOf('.') < dl) ? dividend.substring(dl + 1) : dividend.substring(dl); | ||
if (dvnd.indexOf('.') > -1) { | ||
var shift = dvnd.length - dvnd.indexOf('.') - 1; | ||
dvnd = dvnd.replace('.', ''); | ||
if (dl > dvnd.length) { | ||
shift += dl - dvnd.length; | ||
dvnd = dvnd + (new Array(dl - dvnd.length + 1)).join('0'); | ||
} | ||
prec = shift; | ||
quotent = '0.' + (new Array(shift)).join('0'); | ||
} | ||
precission = precission + 2; | ||
while (prec <= precission) { | ||
var qt = 0; | ||
while (parseInt(dvnd) >= parseInt(divisor)) { | ||
dvnd = add_1.add(dvnd, '-' + divisor); | ||
qt++; | ||
} | ||
quotent += qt; | ||
if (!dividend) { | ||
if (!prec) | ||
quotent += '.'; | ||
prec++; | ||
dvnd = dvnd + '0'; | ||
} | ||
else { | ||
if (dividend[0] == '.') { | ||
quotent += '.'; | ||
prec++; | ||
dividend = dividend.substring(1); | ||
} | ||
dvnd = dvnd + dividend.substring(0, 1); | ||
dividend = dividend.substring(1); | ||
} | ||
} | ||
return ((neg == 1) ? '-' : '') + add_1.trim(round_1.roundOff(quotent, precission - 2)); | ||
} | ||
exports.divide = divide; | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
function compareTo(number1, number2) { | ||
var _a; | ||
var negative = false; | ||
if (number1[0] == '-' && number2[0] != "-") { | ||
return -1; | ||
} | ||
else if (number1[0] != '-' && number2[0] == '-') { | ||
return 1; | ||
} | ||
else if (number1[0] == '-' && number2[0] == '-') { | ||
number1 = number1.substr(1); | ||
number2 = number2.substr(1); | ||
negative = true; | ||
} | ||
_a = add_1.pad(number1, number2), number1 = _a[0], number2 = _a[1]; | ||
if (number1.localeCompare(number2) == 0) { | ||
return 0; | ||
} | ||
for (var i = 0; i < number1.length; i++) { | ||
if (number1[i] == number2[i]) { | ||
continue; | ||
} | ||
else if (number1[i] > number2[i]) { | ||
if (negative) { | ||
return -1; | ||
} | ||
else { | ||
return 1; | ||
} | ||
} | ||
else { | ||
if (negative) { | ||
return 1; | ||
} | ||
else { | ||
return -1; | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
exports.compareTo = compareTo; | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
function subtract(number1, number2) { | ||
number1 = number1.toString(); | ||
number2 = number2.toString(); | ||
number2 = negate(number2); | ||
return add_1.add(number1, number2); | ||
} | ||
exports.subtract = subtract; | ||
function negate(number) { | ||
if (number[0] == '-') { | ||
number = number.substr(1); | ||
} | ||
else { | ||
number = '-' + number; | ||
} | ||
return number; | ||
} | ||
exports.negate = negate; | ||
/***/ }) | ||
/******/ ]); | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.bigDecimal=t():e.bigDecimal=t()}(global,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){"use strict";function r(e){for(var t="",n=e.length,r=e.split(".")[1],i=r?r.length:0,o=0;o<n;o++)e[o]>="0"&&e[o]<="9"?t+=9-parseInt(e[o]):t+=e[o];return u(t,i>0?"0."+new Array(i).join("0")+"1":"1")}function i(e){var t=e.split(".");for(t[0]||(t[0]="0");"0"==t[0][0]&&t[0].length>1;)t[0]=t[0].substring(1);return t[0]+(t[1]?"."+t[1]:"")}function o(e,t){var n=e.split("."),r=t.split("."),i=n[0].length,o=r[0].length;return i>o?r[0]=new Array(Math.abs(i-o)+1).join("0")+(r[0]?r[0]:""):n[0]=new Array(Math.abs(i-o)+1).join("0")+(n[0]?n[0]:""),i=n[1]?n[1].length:0,o=r[1]?r[1].length:0,(i||o)&&(i>o?r[1]=(r[1]?r[1]:"")+new Array(Math.abs(i-o)+1).join("0"):n[1]=(n[1]?n[1]:"")+new Array(Math.abs(i-o)+1).join("0")),[e=n[0]+(n[1]?"."+n[1]:""),t=r[0]+(r[1]?"."+r[1]:"")]}function u(e,t){e=(n=o(e,t))[0],t=n[1];for(var n,r="",i=0,u=e.length-1;u>=0;u--)if("."!==e[u]){var a=parseInt(e[u])+parseInt(t[u])+i;r=a%10+r,i=Math.floor(a/10)}else r="."+r;return i?i.toString()+r:r}Object.defineProperty(t,"__esModule",{value:!0}),t.add=function(e,t){void 0===t&&(t="0");var n=0,a=-1;"-"==e[0]&&(n++,a=1,(e=e.substring(1)).length),"-"==t[0]&&(n++,a=2,(t=t.substring(1)).length),e=i(e),t=i(t),e=(s=o(i(e),i(t)))[0],t=s[1],1==n&&(1==a?e=r(e):t=r(t));var s,l=u(e,t);return n?2==n?"-"+i(l):e.length<l.length?i(l.substring(1)):"-"+i(r(l)):i(l)},t.trim=i,t.pad=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.CEILING=0]="CEILING",e[e.DOWN=1]="DOWN",e[e.FLOOR=2]="FLOOR",e[e.HALF_DOWN=3]="HALF_DOWN",e[e.HALF_EVEN=4]="HALF_EVEN",e[e.HALF_UP=5]="HALF_UP",e[e.UNNECESSARY=6]="UNNECESSARY",e[e.UP=7]="UP"}(t.RoundingModes||(t.RoundingModes={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);function i(e,t,n,i){if(!e||e===new Array(e.length+1).join("0"))return!1;if(i===r.RoundingModes.DOWN||!n&&i===r.RoundingModes.FLOOR||n&&i===r.RoundingModes.CEILING)return!1;if(i===r.RoundingModes.UP||n&&i===r.RoundingModes.FLOOR||!n&&i===r.RoundingModes.CEILING)return!0;var o="5"+new Array(e.length).join("0");if(e>o)return!0;if(e<o)return!1;switch(i){case r.RoundingModes.HALF_DOWN:return!1;case r.RoundingModes.HALF_UP:return!0;case r.RoundingModes.HALF_EVEN:default:return parseInt(t[t.length-1])%2==1}}function o(e,t){void 0===t&&(t=0),t||(t=1),"number"==typeof e&&e.toString();for(var n="",r=e.length-1;r>=0;r--){var i=parseInt(e[r])+t;10==i?(t=1,i=0):t=0,n+=i}return t&&(n+=t),n.split("").reverse().join("")}t.roundOff=function e(t,n,u){if(void 0===n&&(n=0),void 0===u&&(u=r.RoundingModes.HALF_EVEN),u===r.RoundingModes.UNNECESSARY)throw new Error("UNNECESSARY Rounding Mode has not yet been implemented");"number"==typeof t&&(t=t.toString());var a=!1;"-"===t[0]&&(a=!0,t=t.substring(1));var s=t.split("."),l=s[0],f=s[1];if(n<0){if(n=-n,l.length<=n)return"0";var d=l.substr(0,l.length-n);return(a?"-":"")+(d=e(t=d+"."+l.substr(l.length-n)+f,0,u))+new Array(n+1).join("0")}if(0==n)return l.length,i(s[1],l,a,u)?(a?"-":"")+o(l):(a?"-":"")+l;if(!s[1])return(a?"-":"")+l+"."+new Array(n+1).join("0");if(s[1].length<n)return(a?"-":"")+l+"."+s[1]+new Array(n-s[1].length+1).join("0");f=s[1].substring(0,n);var g=s[1].substring(n);return g&&i(g,f,a,u)&&(f=o(f)).length>n?o(l,parseInt(f[0]))+"."+f.substring(1):(a?"-":"")+l+"."+f}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);function i(e){return e="-"==e[0]?e.substr(1):"-"+e}t.subtract=function(e,t){return e=e.toString(),t=i(t=t.toString()),r.add(e,t)},t.negate=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);t.compareTo=function(e,t){var n,i=!1;if("-"==e[0]&&"-"!=t[0])return-1;if("-"!=e[0]&&"-"==t[0])return 1;if("-"==e[0]&&"-"==t[0]&&(e=e.substr(1),t=t.substr(1),i=!0),e=(n=r.pad(e,t))[0],t=n[1],0==e.localeCompare(t))return 0;for(var o=0;o<e.length;o++)if(e[o]!=t[o])return e[o]>t[o]?i?-1:1:i?1:-1;return 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n(2);t.divide=function(e,t,n){if(void 0===n&&(n=8),0==t)throw new Error("Cannot divide by 0");if(e=e.toString(),t=t.toString(),0==e)return"0";var o=0;"-"==t[0]&&(t=t.substring(1),o++),"-"==e[0]&&(e=e.substring(1),o++);var u=t.indexOf(".")>0?t.length-t.indexOf(".")-1:-1;if(t=r.trim(t.replace(".","")),u>=0){var a=e.indexOf(".")>0?e.length-e.indexOf(".")-1:-1;if(-1==a)e=r.trim(e+new Array(u+1).join("0"));else if(u>a)e=e.replace(".",""),e=r.trim(e+new Array(u-a+1).join("0"));else if(u<a){var s=(e=e.replace(".","")).length-u+u;e=r.trim(e.substring(0,s)+"."+e.substring(s))}else u==a&&(e=r.trim(e.replace(".","")))}var l=0,f=t.length,d="",g=e.indexOf(".")>-1&&e.indexOf(".")<f?e.substring(0,f+1):e.substring(0,f);if(e=e.indexOf(".")>-1&&e.indexOf(".")<f?e.substring(f+1):e.substring(f),g.indexOf(".")>-1){var c=g.length-g.indexOf(".")-1;f>(g=g.replace(".","")).length&&(c+=f-g.length,g+=new Array(f-g.length+1).join("0")),l=c,d="0."+new Array(c).join("0")}for(n+=2;l<=n;){for(var v=0;parseInt(g)>=parseInt(t);)g=r.add(g,"-"+t),v++;d+=v,e?("."==e[0]&&(d+=".",l++,e=e.substring(1)),g+=e.substring(0,1),e=e.substring(1)):(l||(d+="."),l++,g+="0")}return(1==o?"-":"")+r.trim(i.roundOff(d,n-2))}},function(e,t,n){"use strict";function r(e){for(;"0"==e[0];)e=e.substr(1);if(-1!=e.indexOf("."))for(;"0"==e[e.length-1];)e=e.substr(0,e.length-1);return""==e||"."==e?e="0":"."==e[e.length-1]&&(e=e.substr(0,e.length-1)),"."==e[0]&&(e="0"+e),e}Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=function(e,t){e=e.toString(),t=t.toString();var n=0;"-"==e[0]&&(n++,e=e.substr(1)),"-"==t[0]&&(n++,t=t.substr(1)),e=r(e),t=r(t);var i=0,o=0;-1!=e.indexOf(".")&&(i=e.length-e.indexOf(".")-1),-1!=t.indexOf(".")&&(o=t.length-t.indexOf(".")-1);var u=i+o;if(e=r(e.replace(".","")),t=r(t.replace(".","")),e.length<t.length){var a=e;e=t,t=a}if("0"==t)return"0";for(var s,l,f=t.length,d=0,g=[],c=f-1,v="",p=0;p<f;p++)g[p]=e.length-1;for(p=0;p<2*e.length;p++){for(var h=0,b=t.length-1;b>=c&&b>=0;b--)g[b]>-1&&g[b]<e.length&&(h+=parseInt(e[g[b]--])*parseInt(t[b]));h+=d,d=Math.floor(h/10),v=h%10+v,c--}return v=r((s=v,0==(l=u)?s:(s=l>=s.length?new Array(l-s.length+1).join("0")+s:s).substr(0,s.length-l)+"."+s.substr(s.length-l,l))),1==n&&(v="-"+v),v}},function(e,t,n){"use strict";var r=n(0),i=n(2),o=n(6),u=n(5),a=n(4),s=n(3),l=n(1),f=function(){function e(t){void 0===t&&(t="0"),this.value=e.validate(t)}return e.validate=function(e){if(e){if(e=e.toString(),isNaN(e))throw Error("Parameter is not a number: "+e);"+"==e[0]&&(e=e.substring(1))}else e="0";if(/e/i.test(e)){var t=e.split(/[eE]/),n=t[0],i=t[1];n=r.trim(n),i=parseInt(i)+n.indexOf("."),e=(n=n.replace(".","")).length<i?n+new Array(i-n.length+1).join("0"):n.length>=i&&i>0?r.trim(n.substring(0,i))+(n.length>i?"."+n.substring(i):""):"0."+new Array(1-i).join("0")+n}return e},e.prototype.getValue=function(){return this.value},e.getPrettyValue=function(t,n,r){if(n||r){if(!n||!r)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else n=3,r=",";var i="-"==(t=e.validate(t)).charAt(0);i&&(t=t.substring(1));for(var o=t.indexOf("."),u="",a=o=o>0?o:t.length;a>0;)a<n?(n=a,a=0):a-=n,u=t.substring(a,a+n)+(a<o-n&&a>=0?r:"")+u;return(i?"-":"")+u+t.substring(o)},e.prototype.getPrettyValue=function(t,n){return e.getPrettyValue(this.value,t,n)},e.round=function(t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=l.RoundingModes.HALF_EVEN),t=e.validate(t),isNaN(n))throw Error("Precision is not a number: "+n);return i.roundOff(t,n,r)},e.prototype.round=function(t,n){if(void 0===t&&(t=0),void 0===n&&(n=l.RoundingModes.HALF_EVEN),isNaN(t))throw Error("Precision is not a number: "+t);return new e(i.roundOff(this.value,t,n))},e.floor=function(t){return-1===(t=e.validate(t)).indexOf(".")?t:e.round(e.subtract(t,.5))},e.prototype.floor=function(){return-1===this.value.indexOf(".")?new e(this.value):this.subtract(new e(.5)).round()},e.ceil=function(t){return-1===(t=e.validate(t)).indexOf(".")?t:e.round(e.add(t,.5))},e.prototype.ceil=function(){return-1===this.value.indexOf(".")?new e(this.value):this.add(new e(.5)).round()},e.add=function(t,n){return t=e.validate(t),n=e.validate(n),r.add(t,n)},e.prototype.add=function(t){return new e(r.add(this.value,t.getValue()))},e.subtract=function(t,n){return t=e.validate(t),n=e.validate(n),s.subtract(t,n)},e.prototype.subtract=function(t){return new e(s.subtract(this.value,t.getValue()))},e.multiply=function(t,n){return t=e.validate(t),n=e.validate(n),o.multiply(t,n)},e.prototype.multiply=function(t){return new e(o.multiply(this.value,t.getValue()))},e.divide=function(t,n,r){return t=e.validate(t),n=e.validate(n),u.divide(t,n,r)},e.prototype.divide=function(t,n){return new e(u.divide(this.value,t.getValue(),n))},e.compareTo=function(t,n){return t=e.validate(t),n=e.validate(n),a.compareTo(t,n)},e.prototype.compareTo=function(e){return a.compareTo(this.value,e.getValue())},e.negate=function(t){return t=e.validate(t),s.negate(t)},e.prototype.negate=function(){return new e(s.negate(this.value))},e.RoundingModes=l.RoundingModes,e}();e.exports=f}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.bigDecimal=t():e.bigDecimal=t()}(global,function(){return r={},i.m=n=[function(e,t,n){"use strict";function u(e){for(var t="",n=e.length,r=e.split(".")[1],i=r?r.length:0,o=0;o<n;o++)"0"<=e[o]&&e[o]<="9"?t+=9-parseInt(e[o]):t+=e[o];return l(t,0<i?"0."+new Array(i).join("0")+"1":"1")}function a(e){var t=e.split(".");for(t[0]||(t[0]="0");"0"==t[0][0]&&1<t[0].length;)t[0]=t[0].substring(1);return t[0]+(t[1]?"."+t[1]:"")}function s(e,t){var n=e.split("."),r=t.split("."),i=n[0].length,o=r[0].length;return o<i?r[0]=new Array(Math.abs(i-o)+1).join("0")+(r[0]?r[0]:""):n[0]=new Array(Math.abs(i-o)+1).join("0")+(n[0]?n[0]:""),i=n[1]?n[1].length:0,o=r[1]?r[1].length:0,(i||o)&&(o<i?r[1]=(r[1]?r[1]:"")+new Array(Math.abs(i-o)+1).join("0"):n[1]=(n[1]?n[1]:"")+new Array(Math.abs(i-o)+1).join("0")),[e=n[0]+(n[1]?"."+n[1]:""),t=r[0]+(r[1]?"."+r[1]:"")]}function l(e,t){var n;e=(n=s(e,t))[0],t=n[1];for(var r="",i=0,o=e.length-1;0<=o;o--)if("."!==e[o]){var u=parseInt(e[o])+parseInt(t[o])+i;r=u%10+r,i=Math.floor(u/10)}else r="."+r;return i?i.toString()+r:r}Object.defineProperty(t,"__esModule",{value:!0}),t.add=function(e,t){var n;void 0===t&&(t="0");var r=0,i=-1;"-"==e[0]&&(r++,i=1,(e=e.substring(1)).length),"-"==t[0]&&(r++,i=2,(t=t.substring(1)).length),e=a(e),t=a(t),e=(n=s(a(e),a(t)))[0],t=n[1],1==r&&(1==i?e=u(e):t=u(t));var o=l(e,t);return r?2==r?"-"+a(o):e.length<o.length?a(o.substring(1)):"-"+a(u(o)):a(o)},t.trim=a,t.pad=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var d=n(2);function f(e,t,n,r){if(!e||e===new Array(e.length+1).join("0"))return!1;if(r===d.RoundingModes.DOWN||!n&&r===d.RoundingModes.FLOOR||n&&r===d.RoundingModes.CEILING)return!1;if(r===d.RoundingModes.UP||n&&r===d.RoundingModes.FLOOR||!n&&r===d.RoundingModes.CEILING)return!0;var i="5"+new Array(e.length).join("0");if(i<e)return!0;if(e<i)return!1;switch(r){case d.RoundingModes.HALF_DOWN:return!1;case d.RoundingModes.HALF_UP:return!0;case d.RoundingModes.HALF_EVEN:default:return parseInt(t[t.length-1])%2==1}}function g(e,t){void 0===t&&(t=0),t||(t=1),"number"==typeof e&&e.toString();for(var n="",r=e.length-1;0<=r;r--){var i=parseInt(e[r])+t;10==i?(t=1,i=0):t=0,n+=i}return t&&(n+=t),n.split("").reverse().join("")}t.roundOff=function e(t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=d.RoundingModes.HALF_EVEN),r===d.RoundingModes.UNNECESSARY)throw new Error("UNNECESSARY Rounding Mode has not yet been implemented");"number"==typeof t&&(t=t.toString());var i=!1;"-"===t[0]&&(i=!0,t=t.substring(1));var o=t.split("."),u=o[0],a=o[1];if(n<0){if(n=-n,u.length<=n)return"0";var s=u.substr(0,u.length-n);return(i?"-":"")+(s=e(t=s+"."+u.substr(u.length-n)+a,0,r))+new Array(n+1).join("0")}if(0==n)return u.length,f(o[1],u,i,r)?(i?"-":"")+g(u):(i?"-":"")+u;if(!o[1])return(i?"-":"")+u+"."+new Array(n+1).join("0");if(o[1].length<n)return(i?"-":"")+u+"."+o[1]+new Array(n-o[1].length+1).join("0");a=o[1].substring(0,n);var l=o[1].substring(n);return l&&f(l,a,i,r)&&(a=g(a)).length>n?g(u,parseInt(a[0]))+"."+a.substring(1):(i?"-":"")+u+"."+a}},function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),(r=t.RoundingModes||(t.RoundingModes={}))[r.CEILING=0]="CEILING",r[r.DOWN=1]="DOWN",r[r.FLOOR=2]="FLOOR",r[r.HALF_DOWN=3]="HALF_DOWN",r[r.HALF_EVEN=4]="HALF_EVEN",r[r.HALF_UP=5]="HALF_UP",r[r.UNNECESSARY=6]="UNNECESSARY",r[r.UP=7]="UP"},function(e,t,n){"use strict";var i=n(0),r=n(1),o=n(4),u=n(5),a=n(6),s=n(7),l=n(2),d=(f.validate=function(e){if(e){if(e=e.toString(),isNaN(e))throw Error("Parameter is not a number: "+e);"+"==e[0]&&(e=e.substring(1))}else e="0";if(/e/i.test(e)){var t=e.split(/[eE]/),n=t[0],r=t[1];n=i.trim(n),r=parseInt(r)+n.indexOf("."),e=(n=n.replace(".","")).length<r?n+new Array(r-n.length+1).join("0"):n.length>=r&&0<r?i.trim(n.substring(0,r))+(n.length>r?"."+n.substring(r):""):"0."+new Array(1-r).join("0")+n}return e},f.prototype.getValue=function(){return this.value},f.getPrettyValue=function(e,t,n){if(t||n){if(!t||!n)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else t=3,n=",";var r="-"==(e=f.validate(e)).charAt(0);r&&(e=e.substring(1));for(var i=e.indexOf("."),o="",u=i=0<i?i:e.length;0<u;)u<t?(t=u,u=0):u-=t,o=e.substring(u,u+t)+(u<i-t&&0<=u?n:"")+o;return(r?"-":"")+o+e.substring(i)},f.prototype.getPrettyValue=function(e,t){return f.getPrettyValue(this.value,e,t)},f.round=function(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n=l.RoundingModes.HALF_EVEN),e=f.validate(e),isNaN(t))throw Error("Precision is not a number: "+t);return r.roundOff(e,t,n)},f.prototype.round=function(e,t){if(void 0===e&&(e=0),void 0===t&&(t=l.RoundingModes.HALF_EVEN),isNaN(e))throw Error("Precision is not a number: "+e);return new f(r.roundOff(this.value,e,t))},f.floor=function(e){return-1===(e=f.validate(e)).indexOf(".")?e:f.round(f.subtract(e,.5))},f.prototype.floor=function(){return-1===this.value.indexOf(".")?new f(this.value):this.subtract(new f(.5)).round()},f.ceil=function(e){return-1===(e=f.validate(e)).indexOf(".")?e:f.round(f.add(e,.5))},f.prototype.ceil=function(){return-1===this.value.indexOf(".")?new f(this.value):this.add(new f(.5)).round()},f.add=function(e,t){return e=f.validate(e),t=f.validate(t),i.add(e,t)},f.prototype.add=function(e){return new f(i.add(this.value,e.getValue()))},f.subtract=function(e,t){return e=f.validate(e),t=f.validate(t),s.subtract(e,t)},f.prototype.subtract=function(e){return new f(s.subtract(this.value,e.getValue()))},f.multiply=function(e,t){return e=f.validate(e),t=f.validate(t),o.multiply(e,t)},f.prototype.multiply=function(e){return new f(o.multiply(this.value,e.getValue()))},f.divide=function(e,t,n){return e=f.validate(e),t=f.validate(t),u.divide(e,t,n)},f.prototype.divide=function(e,t){return new f(u.divide(this.value,e.getValue(),t))},f.compareTo=function(e,t){return e=f.validate(e),t=f.validate(t),a.compareTo(e,t)},f.prototype.compareTo=function(e){return a.compareTo(this.value,e.getValue())},f.negate=function(e){return e=f.validate(e),s.negate(e)},f.prototype.negate=function(){return new f(s.negate(this.value))},f.RoundingModes=l.RoundingModes,f);function f(e){void 0===e&&(e="0"),this.value=f.validate(e)}e.exports=d},function(e,t,n){"use strict";function v(e){for(;"0"==e[0];)e=e.substr(1);if(-1!=e.indexOf("."))for(;"0"==e[e.length-1];)e=e.substr(0,e.length-1);return""==e||"."==e?e="0":"."==e[e.length-1]&&(e=e.substr(0,e.length-1)),"."==e[0]&&(e="0"+e),e}Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=function(e,t){e=e.toString(),t=t.toString();var n=0;"-"==e[0]&&(n++,e=e.substr(1)),"-"==t[0]&&(n++,t=t.substr(1)),e=v(e),t=v(t);var r=0,i=0;-1!=e.indexOf(".")&&(r=e.length-e.indexOf(".")-1),-1!=t.indexOf(".")&&(i=t.length-t.indexOf(".")-1);var o=r+i;if(e=v(e.replace(".","")),t=v(t.replace(".","")),e.length<t.length){var u=e;e=t,t=u}if("0"==t)return"0";for(var a=t.length,s=0,l=[],d=a-1,f="",g=0;g<a;g++)l[g]=e.length-1;for(g=0;g<2*e.length;g++){for(var c=0,p=t.length-1;d<=p&&0<=p;p--)-1<l[p]&&l[p]<e.length&&(c+=parseInt(e[l[p]--])*parseInt(t[p]));c+=s,s=Math.floor(c/10),f=c%10+f,d--}return f=v(function(e,t){return 0==t?e:(e=t>=e.length?new Array(t-e.length+1).join("0")+e:e).substr(0,e.length-t)+"."+e.substr(e.length-t,t)}(f,o)),1==n&&(f="-"+f),f}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var c=n(0),p=n(1);t.divide=function(e,t,n){if(void 0===n&&(n=8),0==t)throw new Error("Cannot divide by 0");if(e=e.toString(),t=t.toString(),e=e.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),t=t.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),0==e)return"0";var r=0;"-"==t[0]&&(t=t.substring(1),r++),"-"==e[0]&&(e=e.substring(1),r++);var i=0<t.indexOf(".")?t.length-t.indexOf(".")-1:-1;if(t=c.trim(t.replace(".","")),0<=i){var o=0<e.indexOf(".")?e.length-e.indexOf(".")-1:-1;if(-1==o)e=c.trim(e+new Array(1+i).join("0"));else if(o<i)e=e.replace(".",""),e=c.trim(e+new Array(i-o+1).join("0"));else if(i<o){var u=(e=e.replace(".","")).length-o+i;e=c.trim(e.substring(0,u)+"."+e.substring(u))}else i==o&&(e=c.trim(e.replace(".","")))}var a=0,s=t.length,l="",d=-1<e.indexOf(".")&&e.indexOf(".")<s?e.substring(0,s+1):e.substring(0,s);if(e=-1<e.indexOf(".")&&e.indexOf(".")<s?e.substring(s+1):e.substring(s),-1<d.indexOf(".")){var f=d.length-d.indexOf(".")-1;s>(d=d.replace(".","")).length&&(f+=s-d.length,d+=new Array(s-d.length+1).join("0")),a=f,l="0."+new Array(f).join("0")}for(n+=2;a<=n;){for(var g=0;parseInt(d)>=parseInt(t);)d=c.add(d,"-"+t),g++;l+=g,e?("."==e[0]&&(l+=".",a++,e=e.substring(1)),d+=e.substring(0,1),e=e.substring(1)):(a||(l+="."),a++,d+="0")}return(1==r?"-":"")+c.trim(p.roundOff(l,n-2))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(0);t.compareTo=function(e,t){var n,r=!1;if("-"==e[0]&&"-"!=t[0])return-1;if("-"!=e[0]&&"-"==t[0])return 1;if("-"==e[0]&&"-"==t[0]&&(e=e.substr(1),t=t.substr(1),r=!0),e=(n=o.pad(e,t))[0],t=n[1],0==e.localeCompare(t))return 0;for(var i=0;i<e.length;i++)if(e[i]!=t[i])return e[i]>t[i]?r?-1:1:r?1:-1;return 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);function i(e){return e="-"==e[0]?e.substr(1):"-"+e}t.subtract=function(e,t){return e=e.toString(),t=i(t=t.toString()),r.add(e,t)},t.negate=i}],i.c=r,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=3);function i(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}var n,r}); |
@@ -37,3 +37,3 @@ export declare enum RoundingModes { | ||
*/ | ||
UP = 7, | ||
UP = 7 | ||
} |
@@ -40,7 +40,3 @@ var bigDecimal = | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); | ||
/******/ } | ||
@@ -51,5 +47,24 @@ /******/ }; | ||
/******/ __webpack_require__.r = function(exports) { | ||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | ||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | ||
/******/ } | ||
/******/ Object.defineProperty(exports, '__esModule', { value: true }); | ||
/******/ }; | ||
/******/ | ||
/******/ // create a fake namespace object | ||
/******/ // mode & 1: value is a module id, require it | ||
/******/ // mode & 2: merge all properties of value into the ns | ||
/******/ // mode & 4: return value when already ns object | ||
/******/ // mode & 8|1: behave like require | ||
/******/ __webpack_require__.t = function(value, mode) { | ||
/******/ if(mode & 1) value = __webpack_require__(value); | ||
/******/ if(mode & 8) return value; | ||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; | ||
/******/ var ns = Object.create(null); | ||
/******/ __webpack_require__.r(ns); | ||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); | ||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); | ||
/******/ return ns; | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
@@ -72,3 +87,3 @@ /******/ __webpack_require__.n = function(module) { | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 7); | ||
/******/ return __webpack_require__(__webpack_require__.s = 3); | ||
/******/ }) | ||
@@ -85,2 +100,3 @@ /************************************************************************/ | ||
function add(number1, number2) { | ||
var _a; | ||
if (number2 === void 0) { number2 = "0"; } | ||
@@ -121,3 +137,2 @@ var neg = 0, ind = -1, neg_len; | ||
} | ||
var _a; | ||
} | ||
@@ -172,2 +187,3 @@ exports.add = add; | ||
function addCore(number1, number2) { | ||
var _a; | ||
_a = pad(number1, number2), number1 = _a[0], number2 = _a[1]; | ||
@@ -185,3 +201,2 @@ var sum = '', carry = 0; | ||
return carry ? (carry.toString() + sum) : sum; | ||
var _a; | ||
} | ||
@@ -197,51 +212,3 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var RoundingModes; | ||
(function (RoundingModes) { | ||
/** | ||
* Rounding mode to round towards positive infinity. | ||
*/ | ||
RoundingModes[RoundingModes["CEILING"] = 0] = "CEILING"; | ||
/** | ||
* Rounding mode to round towards zero. | ||
*/ | ||
RoundingModes[RoundingModes["DOWN"] = 1] = "DOWN"; | ||
/** | ||
* Rounding mode to round towards negative infinity. | ||
*/ | ||
RoundingModes[RoundingModes["FLOOR"] = 2] = "FLOOR"; | ||
/** | ||
* Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case round down. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_DOWN"] = 3] = "HALF_DOWN"; | ||
/** | ||
* Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case, round towards the even neighbor. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_EVEN"] = 4] = "HALF_EVEN"; | ||
/** | ||
* Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case round up. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_UP"] = 5] = "HALF_UP"; | ||
/** | ||
* Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary. | ||
* UNIMPLEMENTED | ||
*/ | ||
RoundingModes[RoundingModes["UNNECESSARY"] = 6] = "UNNECESSARY"; | ||
/** | ||
* Rounding mode to round away from zero. | ||
*/ | ||
RoundingModes[RoundingModes["UP"] = 7] = "UP"; | ||
})(RoundingModes = exports.RoundingModes || (exports.RoundingModes = {})); | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var roundingModes_1 = __webpack_require__(1); | ||
var roundingModes_1 = __webpack_require__(2); | ||
/** | ||
@@ -355,3 +322,3 @@ * | ||
/***/ }), | ||
/* 3 */ | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -362,24 +329,45 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
function subtract(number1, number2) { | ||
number1 = number1.toString(); | ||
number2 = number2.toString(); | ||
number2 = negate(number2); | ||
return add_1.add(number1, number2); | ||
} | ||
exports.subtract = subtract; | ||
function negate(number) { | ||
if (number[0] == '-') { | ||
number = number.substr(1); | ||
} | ||
else { | ||
number = '-' + number; | ||
} | ||
return number; | ||
} | ||
exports.negate = negate; | ||
var RoundingModes; | ||
(function (RoundingModes) { | ||
/** | ||
* Rounding mode to round towards positive infinity. | ||
*/ | ||
RoundingModes[RoundingModes["CEILING"] = 0] = "CEILING"; | ||
/** | ||
* Rounding mode to round towards zero. | ||
*/ | ||
RoundingModes[RoundingModes["DOWN"] = 1] = "DOWN"; | ||
/** | ||
* Rounding mode to round towards negative infinity. | ||
*/ | ||
RoundingModes[RoundingModes["FLOOR"] = 2] = "FLOOR"; | ||
/** | ||
* Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case round down. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_DOWN"] = 3] = "HALF_DOWN"; | ||
/** | ||
* Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case, round towards the even neighbor. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_EVEN"] = 4] = "HALF_EVEN"; | ||
/** | ||
* Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, | ||
* in which case round up. | ||
*/ | ||
RoundingModes[RoundingModes["HALF_UP"] = 5] = "HALF_UP"; | ||
/** | ||
* Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary. | ||
* UNIMPLEMENTED | ||
*/ | ||
RoundingModes[RoundingModes["UNNECESSARY"] = 6] = "UNNECESSARY"; | ||
/** | ||
* Rounding mode to round away from zero. | ||
*/ | ||
RoundingModes[RoundingModes["UP"] = 7] = "UP"; | ||
})(RoundingModes = exports.RoundingModes || (exports.RoundingModes = {})); | ||
/***/ }), | ||
/* 4 */ | ||
/* 3 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -389,261 +377,9 @@ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
function compareTo(number1, number2) { | ||
var negative = false; | ||
if (number1[0] == '-' && number2[0] != "-") { | ||
return -1; | ||
} | ||
else if (number1[0] != '-' && number2[0] == '-') { | ||
return 1; | ||
} | ||
else if (number1[0] == '-' && number2[0] == '-') { | ||
number1 = number1.substr(1); | ||
number2 = number2.substr(1); | ||
negative = true; | ||
} | ||
_a = add_1.pad(number1, number2), number1 = _a[0], number2 = _a[1]; | ||
if (number1.localeCompare(number2) == 0) { | ||
return 0; | ||
} | ||
for (var i = 0; i < number1.length; i++) { | ||
if (number1[i] == number2[i]) { | ||
continue; | ||
} | ||
else if (number1[i] > number2[i]) { | ||
if (negative) { | ||
return -1; | ||
} | ||
else { | ||
return 1; | ||
} | ||
} | ||
else { | ||
if (negative) { | ||
return 1; | ||
} | ||
else { | ||
return -1; | ||
} | ||
} | ||
} | ||
return 0; | ||
var _a; | ||
} | ||
exports.compareTo = compareTo; | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
var round_1 = __webpack_require__(2); | ||
function divide(dividend, divisor, precission) { | ||
if (precission === void 0) { precission = 8; } | ||
if (divisor == 0) { | ||
throw new Error('Cannot divide by 0'); | ||
} | ||
dividend = dividend.toString(); | ||
divisor = divisor.toString(); | ||
if (dividend == 0) | ||
return '0'; | ||
var neg = 0; | ||
if (divisor[0] == '-') { | ||
divisor = divisor.substring(1); | ||
neg++; | ||
} | ||
if (dividend[0] == '-') { | ||
dividend = dividend.substring(1); | ||
neg++; | ||
} | ||
var pt_dvsr = divisor.indexOf('.') > 0 ? divisor.length - divisor.indexOf('.') - 1 : -1; | ||
divisor = add_1.trim(divisor.replace('.', '')); | ||
if (pt_dvsr >= 0) { | ||
var pt_dvnd = dividend.indexOf('.') > 0 ? dividend.length - dividend.indexOf('.') - 1 : -1; | ||
if (pt_dvnd == -1) { | ||
dividend = add_1.trim(dividend + (new Array(pt_dvsr + 1)).join('0')); | ||
} | ||
else { | ||
if (pt_dvsr > pt_dvnd) { | ||
dividend = dividend.replace('.', ''); | ||
dividend = add_1.trim(dividend + (new Array(pt_dvsr - pt_dvnd + 1)).join('0')); | ||
} | ||
else if (pt_dvsr < pt_dvnd) { | ||
dividend = dividend.replace('.', ''); | ||
var loc = dividend.length - pt_dvsr + pt_dvsr; | ||
dividend = add_1.trim(dividend.substring(0, loc) + '.' + dividend.substring(loc)); | ||
} | ||
else if (pt_dvsr == pt_dvnd) { | ||
dividend = add_1.trim(dividend.replace('.', '')); | ||
} | ||
} | ||
} | ||
var prec = 0, dl = divisor.length, rem = '0', quotent = ''; | ||
var dvnd = (dividend.indexOf('.') > -1 && dividend.indexOf('.') < dl) ? dividend.substring(0, dl + 1) : dividend.substring(0, dl); | ||
dividend = (dividend.indexOf('.') > -1 && dividend.indexOf('.') < dl) ? dividend.substring(dl + 1) : dividend.substring(dl); | ||
if (dvnd.indexOf('.') > -1) { | ||
var shift = dvnd.length - dvnd.indexOf('.') - 1; | ||
dvnd = dvnd.replace('.', ''); | ||
if (dl > dvnd.length) { | ||
shift += dl - dvnd.length; | ||
dvnd = dvnd + (new Array(dl - dvnd.length + 1)).join('0'); | ||
} | ||
prec = shift; | ||
quotent = '0.' + (new Array(shift)).join('0'); | ||
} | ||
precission = precission + 2; | ||
while (prec <= precission) { | ||
var qt = 0; | ||
while (parseInt(dvnd) >= parseInt(divisor)) { | ||
dvnd = add_1.add(dvnd, '-' + divisor); | ||
qt++; | ||
} | ||
quotent += qt; | ||
if (!dividend) { | ||
if (!prec) | ||
quotent += '.'; | ||
prec++; | ||
dvnd = dvnd + '0'; | ||
} | ||
else { | ||
if (dividend[0] == '.') { | ||
quotent += '.'; | ||
prec++; | ||
dividend = dividend.substring(1); | ||
} | ||
dvnd = dvnd + dividend.substring(0, 1); | ||
dividend = dividend.substring(1); | ||
} | ||
} | ||
return ((neg == 1) ? '-' : '') + add_1.trim(round_1.roundOff(quotent, precission - 2)); | ||
} | ||
exports.divide = divide; | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function multiply(number1, number2) { | ||
number1 = number1.toString(); | ||
number2 = number2.toString(); | ||
/*Filter numbers*/ | ||
var negative = 0; | ||
if (number1[0] == '-') { | ||
negative++; | ||
number1 = number1.substr(1); | ||
} | ||
if (number2[0] == '-') { | ||
negative++; | ||
number2 = number2.substr(1); | ||
} | ||
number1 = trailZero(number1); | ||
number2 = trailZero(number2); | ||
var decimalLength1 = 0; | ||
var decimalLength2 = 0; | ||
if (number1.indexOf('.') != -1) { | ||
decimalLength1 = number1.length - number1.indexOf('.') - 1; | ||
} | ||
if (number2.indexOf('.') != -1) { | ||
decimalLength2 = number2.length - number2.indexOf('.') - 1; | ||
} | ||
var decimalLength = decimalLength1 + decimalLength2; | ||
number1 = trailZero(number1.replace('.', '')); | ||
number2 = trailZero(number2.replace('.', '')); | ||
if (number1.length < number2.length) { | ||
var temp = number1; | ||
number1 = number2; | ||
number2 = temp; | ||
} | ||
if (number2 == '0') { | ||
return '0'; | ||
} | ||
/* | ||
* Core multiplication | ||
*/ | ||
var length = number2.length; | ||
var carry = 0; | ||
var positionVector = []; | ||
var currentPosition = length - 1; | ||
var result = ""; | ||
for (var i = 0; i < length; i++) { | ||
positionVector[i] = number1.length - 1; | ||
} | ||
for (var i = 0; i < 2 * number1.length; i++) { | ||
var sum = 0; | ||
for (var j = number2.length - 1; j >= currentPosition && j >= 0; j--) { | ||
if (positionVector[j] > -1 && positionVector[j] < number1.length) { | ||
sum += parseInt(number1[positionVector[j]--]) * parseInt(number2[j]); | ||
} | ||
} | ||
sum += carry; | ||
carry = Math.floor(sum / 10); | ||
result = sum % 10 + result; | ||
currentPosition--; | ||
} | ||
/* | ||
* Formatting result | ||
*/ | ||
result = trailZero(adjustDecimal(result, decimalLength)); | ||
if (negative == 1) { | ||
result = '-' + result; | ||
} | ||
return result; | ||
} | ||
exports.multiply = multiply; | ||
/* | ||
* Add decimal point | ||
*/ | ||
function adjustDecimal(number, decimal) { | ||
if (decimal == 0) | ||
return number; | ||
else { | ||
number = (decimal >= number.length) ? ((new Array(decimal - number.length + 1)).join('0') + number) : number; | ||
return number.substr(0, number.length - decimal) + '.' + number.substr(number.length - decimal, decimal); | ||
} | ||
} | ||
/* | ||
* Removes zero from front and back*/ | ||
function trailZero(number) { | ||
while (number[0] == '0') { | ||
number = number.substr(1); | ||
} | ||
if (number.indexOf('.') != -1) { | ||
while (number[number.length - 1] == '0') { | ||
number = number.substr(0, number.length - 1); | ||
} | ||
} | ||
if (number == "" || number == ".") { | ||
number = '0'; | ||
} | ||
else if (number[number.length - 1] == '.') { | ||
number = number.substr(0, number.length - 1); | ||
} | ||
if (number[0] == '.') { | ||
number = '0' + number; | ||
} | ||
return number; | ||
} | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var add_1 = __webpack_require__(0); | ||
var round_1 = __webpack_require__(2); | ||
var multiply_1 = __webpack_require__(6); | ||
var round_1 = __webpack_require__(1); | ||
var multiply_1 = __webpack_require__(4); | ||
var divide_1 = __webpack_require__(5); | ||
var compareTo_1 = __webpack_require__(4); | ||
var subtract_1 = __webpack_require__(3); | ||
var roundingModes_1 = __webpack_require__(1); | ||
var compareTo_1 = __webpack_require__(6); | ||
var subtract_1 = __webpack_require__(7); | ||
var roundingModes_1 = __webpack_require__(2); | ||
var bigDecimal = /** @class */ (function () { | ||
@@ -805,3 +541,285 @@ function bigDecimal(number) { | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function multiply(number1, number2) { | ||
number1 = number1.toString(); | ||
number2 = number2.toString(); | ||
/*Filter numbers*/ | ||
var negative = 0; | ||
if (number1[0] == '-') { | ||
negative++; | ||
number1 = number1.substr(1); | ||
} | ||
if (number2[0] == '-') { | ||
negative++; | ||
number2 = number2.substr(1); | ||
} | ||
number1 = trailZero(number1); | ||
number2 = trailZero(number2); | ||
var decimalLength1 = 0; | ||
var decimalLength2 = 0; | ||
if (number1.indexOf('.') != -1) { | ||
decimalLength1 = number1.length - number1.indexOf('.') - 1; | ||
} | ||
if (number2.indexOf('.') != -1) { | ||
decimalLength2 = number2.length - number2.indexOf('.') - 1; | ||
} | ||
var decimalLength = decimalLength1 + decimalLength2; | ||
number1 = trailZero(number1.replace('.', '')); | ||
number2 = trailZero(number2.replace('.', '')); | ||
if (number1.length < number2.length) { | ||
var temp = number1; | ||
number1 = number2; | ||
number2 = temp; | ||
} | ||
if (number2 == '0') { | ||
return '0'; | ||
} | ||
/* | ||
* Core multiplication | ||
*/ | ||
var length = number2.length; | ||
var carry = 0; | ||
var positionVector = []; | ||
var currentPosition = length - 1; | ||
var result = ""; | ||
for (var i = 0; i < length; i++) { | ||
positionVector[i] = number1.length - 1; | ||
} | ||
for (var i = 0; i < 2 * number1.length; i++) { | ||
var sum = 0; | ||
for (var j = number2.length - 1; j >= currentPosition && j >= 0; j--) { | ||
if (positionVector[j] > -1 && positionVector[j] < number1.length) { | ||
sum += parseInt(number1[positionVector[j]--]) * parseInt(number2[j]); | ||
} | ||
} | ||
sum += carry; | ||
carry = Math.floor(sum / 10); | ||
result = sum % 10 + result; | ||
currentPosition--; | ||
} | ||
/* | ||
* Formatting result | ||
*/ | ||
result = trailZero(adjustDecimal(result, decimalLength)); | ||
if (negative == 1) { | ||
result = '-' + result; | ||
} | ||
return result; | ||
} | ||
exports.multiply = multiply; | ||
/* | ||
* Add decimal point | ||
*/ | ||
function adjustDecimal(number, decimal) { | ||
if (decimal == 0) | ||
return number; | ||
else { | ||
number = (decimal >= number.length) ? ((new Array(decimal - number.length + 1)).join('0') + number) : number; | ||
return number.substr(0, number.length - decimal) + '.' + number.substr(number.length - decimal, decimal); | ||
} | ||
} | ||
/* | ||
* Removes zero from front and back*/ | ||
function trailZero(number) { | ||
while (number[0] == '0') { | ||
number = number.substr(1); | ||
} | ||
if (number.indexOf('.') != -1) { | ||
while (number[number.length - 1] == '0') { | ||
number = number.substr(0, number.length - 1); | ||
} | ||
} | ||
if (number == "" || number == ".") { | ||
number = '0'; | ||
} | ||
else if (number[number.length - 1] == '.') { | ||
number = number.substr(0, number.length - 1); | ||
} | ||
if (number[0] == '.') { | ||
number = '0' + number; | ||
} | ||
return number; | ||
} | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
var round_1 = __webpack_require__(1); | ||
function divide(dividend, divisor, precission) { | ||
if (precission === void 0) { precission = 8; } | ||
if (divisor == 0) { | ||
throw new Error('Cannot divide by 0'); | ||
} | ||
dividend = dividend.toString(); | ||
divisor = divisor.toString(); | ||
// remove trailing zeros in decimal ISSUE#18 | ||
dividend = dividend.replace(/(\.\d*?[1-9])0+$/g, "$1").replace(/\.0+$/, ""); | ||
divisor = divisor.replace(/(\.\d*?[1-9])0+$/g, "$1").replace(/\.0+$/, ""); | ||
if (dividend == 0) | ||
return '0'; | ||
var neg = 0; | ||
if (divisor[0] == '-') { | ||
divisor = divisor.substring(1); | ||
neg++; | ||
} | ||
if (dividend[0] == '-') { | ||
dividend = dividend.substring(1); | ||
neg++; | ||
} | ||
var pt_dvsr = divisor.indexOf('.') > 0 ? divisor.length - divisor.indexOf('.') - 1 : -1; | ||
divisor = add_1.trim(divisor.replace('.', '')); | ||
if (pt_dvsr >= 0) { | ||
var pt_dvnd = dividend.indexOf('.') > 0 ? dividend.length - dividend.indexOf('.') - 1 : -1; | ||
if (pt_dvnd == -1) { | ||
dividend = add_1.trim(dividend + (new Array(pt_dvsr + 1)).join('0')); | ||
} | ||
else { | ||
if (pt_dvsr > pt_dvnd) { | ||
dividend = dividend.replace('.', ''); | ||
dividend = add_1.trim(dividend + (new Array(pt_dvsr - pt_dvnd + 1)).join('0')); | ||
} | ||
else if (pt_dvsr < pt_dvnd) { | ||
dividend = dividend.replace('.', ''); | ||
var loc = dividend.length - pt_dvnd + pt_dvsr; | ||
dividend = add_1.trim(dividend.substring(0, loc) + '.' + dividend.substring(loc)); | ||
} | ||
else if (pt_dvsr == pt_dvnd) { | ||
dividend = add_1.trim(dividend.replace('.', '')); | ||
} | ||
} | ||
} | ||
var prec = 0, dl = divisor.length, rem = '0', quotent = ''; | ||
var dvnd = (dividend.indexOf('.') > -1 && dividend.indexOf('.') < dl) ? dividend.substring(0, dl + 1) : dividend.substring(0, dl); | ||
dividend = (dividend.indexOf('.') > -1 && dividend.indexOf('.') < dl) ? dividend.substring(dl + 1) : dividend.substring(dl); | ||
if (dvnd.indexOf('.') > -1) { | ||
var shift = dvnd.length - dvnd.indexOf('.') - 1; | ||
dvnd = dvnd.replace('.', ''); | ||
if (dl > dvnd.length) { | ||
shift += dl - dvnd.length; | ||
dvnd = dvnd + (new Array(dl - dvnd.length + 1)).join('0'); | ||
} | ||
prec = shift; | ||
quotent = '0.' + (new Array(shift)).join('0'); | ||
} | ||
precission = precission + 2; | ||
while (prec <= precission) { | ||
var qt = 0; | ||
while (parseInt(dvnd) >= parseInt(divisor)) { | ||
dvnd = add_1.add(dvnd, '-' + divisor); | ||
qt++; | ||
} | ||
quotent += qt; | ||
if (!dividend) { | ||
if (!prec) | ||
quotent += '.'; | ||
prec++; | ||
dvnd = dvnd + '0'; | ||
} | ||
else { | ||
if (dividend[0] == '.') { | ||
quotent += '.'; | ||
prec++; | ||
dividend = dividend.substring(1); | ||
} | ||
dvnd = dvnd + dividend.substring(0, 1); | ||
dividend = dividend.substring(1); | ||
} | ||
} | ||
return ((neg == 1) ? '-' : '') + add_1.trim(round_1.roundOff(quotent, precission - 2)); | ||
} | ||
exports.divide = divide; | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
function compareTo(number1, number2) { | ||
var _a; | ||
var negative = false; | ||
if (number1[0] == '-' && number2[0] != "-") { | ||
return -1; | ||
} | ||
else if (number1[0] != '-' && number2[0] == '-') { | ||
return 1; | ||
} | ||
else if (number1[0] == '-' && number2[0] == '-') { | ||
number1 = number1.substr(1); | ||
number2 = number2.substr(1); | ||
negative = true; | ||
} | ||
_a = add_1.pad(number1, number2), number1 = _a[0], number2 = _a[1]; | ||
if (number1.localeCompare(number2) == 0) { | ||
return 0; | ||
} | ||
for (var i = 0; i < number1.length; i++) { | ||
if (number1[i] == number2[i]) { | ||
continue; | ||
} | ||
else if (number1[i] > number2[i]) { | ||
if (negative) { | ||
return -1; | ||
} | ||
else { | ||
return 1; | ||
} | ||
} | ||
else { | ||
if (negative) { | ||
return 1; | ||
} | ||
else { | ||
return -1; | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
exports.compareTo = compareTo; | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var add_1 = __webpack_require__(0); | ||
function subtract(number1, number2) { | ||
number1 = number1.toString(); | ||
number2 = number2.toString(); | ||
number2 = negate(number2); | ||
return add_1.add(number1, number2); | ||
} | ||
exports.subtract = subtract; | ||
function negate(number) { | ||
if (number[0] == '-') { | ||
number = number.substr(1); | ||
} | ||
else { | ||
number = '-' + number; | ||
} | ||
return number; | ||
} | ||
exports.negate = negate; | ||
/***/ }) | ||
/******/ ]); |
@@ -1,1 +0,1 @@ | ||
var bigDecimal=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){"use strict";function r(e){for(var t="",n=e.length,r=e.split(".")[1],i=r?r.length:0,u=0;u<n;u++)e[u]>="0"&&e[u]<="9"?t+=9-parseInt(e[u]):t+=e[u];return o(t,i>0?"0."+new Array(i).join("0")+"1":"1")}function i(e){var t=e.split(".");for(t[0]||(t[0]="0");"0"==t[0][0]&&t[0].length>1;)t[0]=t[0].substring(1);return t[0]+(t[1]?"."+t[1]:"")}function u(e,t){var n=e.split("."),r=t.split("."),i=n[0].length,u=r[0].length;return i>u?r[0]=new Array(Math.abs(i-u)+1).join("0")+(r[0]?r[0]:""):n[0]=new Array(Math.abs(i-u)+1).join("0")+(n[0]?n[0]:""),i=n[1]?n[1].length:0,u=r[1]?r[1].length:0,(i||u)&&(i>u?r[1]=(r[1]?r[1]:"")+new Array(Math.abs(i-u)+1).join("0"):n[1]=(n[1]?n[1]:"")+new Array(Math.abs(i-u)+1).join("0")),[e=n[0]+(n[1]?"."+n[1]:""),t=r[0]+(r[1]?"."+r[1]:"")]}function o(e,t){e=(n=u(e,t))[0],t=n[1];for(var n,r="",i=0,o=e.length-1;o>=0;o--)if("."!==e[o]){var a=parseInt(e[o])+parseInt(t[o])+i;r=a%10+r,i=Math.floor(a/10)}else r="."+r;return i?i.toString()+r:r}Object.defineProperty(t,"__esModule",{value:!0}),t.add=function(e,t){void 0===t&&(t="0");var n=0,a=-1;"-"==e[0]&&(n++,a=1,(e=e.substring(1)).length),"-"==t[0]&&(n++,a=2,(t=t.substring(1)).length),e=i(e),t=i(t),e=(s=u(i(e),i(t)))[0],t=s[1],1==n&&(1==a?e=r(e):t=r(t));var s,l=o(e,t);return n?2==n?"-"+i(l):e.length<l.length?i(l.substring(1)):"-"+i(r(l)):i(l)},t.trim=i,t.pad=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.CEILING=0]="CEILING",e[e.DOWN=1]="DOWN",e[e.FLOOR=2]="FLOOR",e[e.HALF_DOWN=3]="HALF_DOWN",e[e.HALF_EVEN=4]="HALF_EVEN",e[e.HALF_UP=5]="HALF_UP",e[e.UNNECESSARY=6]="UNNECESSARY",e[e.UP=7]="UP"}(t.RoundingModes||(t.RoundingModes={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);function i(e,t,n,i){if(!e||e===new Array(e.length+1).join("0"))return!1;if(i===r.RoundingModes.DOWN||!n&&i===r.RoundingModes.FLOOR||n&&i===r.RoundingModes.CEILING)return!1;if(i===r.RoundingModes.UP||n&&i===r.RoundingModes.FLOOR||!n&&i===r.RoundingModes.CEILING)return!0;var u="5"+new Array(e.length).join("0");if(e>u)return!0;if(e<u)return!1;switch(i){case r.RoundingModes.HALF_DOWN:return!1;case r.RoundingModes.HALF_UP:return!0;case r.RoundingModes.HALF_EVEN:default:return parseInt(t[t.length-1])%2==1}}function u(e,t){void 0===t&&(t=0),t||(t=1),"number"==typeof e&&e.toString();for(var n="",r=e.length-1;r>=0;r--){var i=parseInt(e[r])+t;10==i?(t=1,i=0):t=0,n+=i}return t&&(n+=t),n.split("").reverse().join("")}t.roundOff=function e(t,n,o){if(void 0===n&&(n=0),void 0===o&&(o=r.RoundingModes.HALF_EVEN),o===r.RoundingModes.UNNECESSARY)throw new Error("UNNECESSARY Rounding Mode has not yet been implemented");"number"==typeof t&&(t=t.toString());var a=!1;"-"===t[0]&&(a=!0,t=t.substring(1));var s=t.split("."),l=s[0],d=s[1];if(n<0){if(n=-n,l.length<=n)return"0";var f=l.substr(0,l.length-n);return(a?"-":"")+(f=e(t=f+"."+l.substr(l.length-n)+d,0,o))+new Array(n+1).join("0")}if(0==n)return l.length,i(s[1],l,a,o)?(a?"-":"")+u(l):(a?"-":"")+l;if(!s[1])return(a?"-":"")+l+"."+new Array(n+1).join("0");if(s[1].length<n)return(a?"-":"")+l+"."+s[1]+new Array(n-s[1].length+1).join("0");d=s[1].substring(0,n);var g=s[1].substring(n);return g&&i(g,d,a,o)&&(d=u(d)).length>n?u(l,parseInt(d[0]))+"."+d.substring(1):(a?"-":"")+l+"."+d}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);function i(e){return e="-"==e[0]?e.substr(1):"-"+e}t.subtract=function(e,t){return e=e.toString(),t=i(t=t.toString()),r.add(e,t)},t.negate=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);t.compareTo=function(e,t){var n,i=!1;if("-"==e[0]&&"-"!=t[0])return-1;if("-"!=e[0]&&"-"==t[0])return 1;if("-"==e[0]&&"-"==t[0]&&(e=e.substr(1),t=t.substr(1),i=!0),e=(n=r.pad(e,t))[0],t=n[1],0==e.localeCompare(t))return 0;for(var u=0;u<e.length;u++)if(e[u]!=t[u])return e[u]>t[u]?i?-1:1:i?1:-1;return 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n(2);t.divide=function(e,t,n){if(void 0===n&&(n=8),0==t)throw new Error("Cannot divide by 0");if(e=e.toString(),t=t.toString(),0==e)return"0";var u=0;"-"==t[0]&&(t=t.substring(1),u++),"-"==e[0]&&(e=e.substring(1),u++);var o=t.indexOf(".")>0?t.length-t.indexOf(".")-1:-1;if(t=r.trim(t.replace(".","")),o>=0){var a=e.indexOf(".")>0?e.length-e.indexOf(".")-1:-1;if(-1==a)e=r.trim(e+new Array(o+1).join("0"));else if(o>a)e=e.replace(".",""),e=r.trim(e+new Array(o-a+1).join("0"));else if(o<a){var s=(e=e.replace(".","")).length-o+o;e=r.trim(e.substring(0,s)+"."+e.substring(s))}else o==a&&(e=r.trim(e.replace(".","")))}var l=0,d=t.length,f="",g=e.indexOf(".")>-1&&e.indexOf(".")<d?e.substring(0,d+1):e.substring(0,d);if(e=e.indexOf(".")>-1&&e.indexOf(".")<d?e.substring(d+1):e.substring(d),g.indexOf(".")>-1){var c=g.length-g.indexOf(".")-1;d>(g=g.replace(".","")).length&&(c+=d-g.length,g+=new Array(d-g.length+1).join("0")),l=c,f="0."+new Array(c).join("0")}for(n+=2;l<=n;){for(var v=0;parseInt(g)>=parseInt(t);)g=r.add(g,"-"+t),v++;f+=v,e?("."==e[0]&&(f+=".",l++,e=e.substring(1)),g+=e.substring(0,1),e=e.substring(1)):(l||(f+="."),l++,g+="0")}return(1==u?"-":"")+r.trim(i.roundOff(f,n-2))}},function(e,t,n){"use strict";function r(e){for(;"0"==e[0];)e=e.substr(1);if(-1!=e.indexOf("."))for(;"0"==e[e.length-1];)e=e.substr(0,e.length-1);return""==e||"."==e?e="0":"."==e[e.length-1]&&(e=e.substr(0,e.length-1)),"."==e[0]&&(e="0"+e),e}Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=function(e,t){e=e.toString(),t=t.toString();var n=0;"-"==e[0]&&(n++,e=e.substr(1)),"-"==t[0]&&(n++,t=t.substr(1)),e=r(e),t=r(t);var i=0,u=0;-1!=e.indexOf(".")&&(i=e.length-e.indexOf(".")-1),-1!=t.indexOf(".")&&(u=t.length-t.indexOf(".")-1);var o=i+u;if(e=r(e.replace(".","")),t=r(t.replace(".","")),e.length<t.length){var a=e;e=t,t=a}if("0"==t)return"0";for(var s,l,d=t.length,f=0,g=[],c=d-1,v="",h=0;h<d;h++)g[h]=e.length-1;for(h=0;h<2*e.length;h++){for(var p=0,b=t.length-1;b>=c&&b>=0;b--)g[b]>-1&&g[b]<e.length&&(p+=parseInt(e[g[b]--])*parseInt(t[b]));p+=f,f=Math.floor(p/10),v=p%10+v,c--}return v=r((s=v,0==(l=o)?s:(s=l>=s.length?new Array(l-s.length+1).join("0")+s:s).substr(0,s.length-l)+"."+s.substr(s.length-l,l))),1==n&&(v="-"+v),v}},function(e,t,n){"use strict";var r=n(0),i=n(2),u=n(6),o=n(5),a=n(4),s=n(3),l=n(1),d=function(){function e(t){void 0===t&&(t="0"),this.value=e.validate(t)}return e.validate=function(e){if(e){if(e=e.toString(),isNaN(e))throw Error("Parameter is not a number: "+e);"+"==e[0]&&(e=e.substring(1))}else e="0";if(/e/i.test(e)){var t=e.split(/[eE]/),n=t[0],i=t[1];n=r.trim(n),i=parseInt(i)+n.indexOf("."),e=(n=n.replace(".","")).length<i?n+new Array(i-n.length+1).join("0"):n.length>=i&&i>0?r.trim(n.substring(0,i))+(n.length>i?"."+n.substring(i):""):"0."+new Array(1-i).join("0")+n}return e},e.prototype.getValue=function(){return this.value},e.getPrettyValue=function(t,n,r){if(n||r){if(!n||!r)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else n=3,r=",";var i="-"==(t=e.validate(t)).charAt(0);i&&(t=t.substring(1));for(var u=t.indexOf("."),o="",a=u=u>0?u:t.length;a>0;)a<n?(n=a,a=0):a-=n,o=t.substring(a,a+n)+(a<u-n&&a>=0?r:"")+o;return(i?"-":"")+o+t.substring(u)},e.prototype.getPrettyValue=function(t,n){return e.getPrettyValue(this.value,t,n)},e.round=function(t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=l.RoundingModes.HALF_EVEN),t=e.validate(t),isNaN(n))throw Error("Precision is not a number: "+n);return i.roundOff(t,n,r)},e.prototype.round=function(t,n){if(void 0===t&&(t=0),void 0===n&&(n=l.RoundingModes.HALF_EVEN),isNaN(t))throw Error("Precision is not a number: "+t);return new e(i.roundOff(this.value,t,n))},e.floor=function(t){return-1===(t=e.validate(t)).indexOf(".")?t:e.round(e.subtract(t,.5))},e.prototype.floor=function(){return-1===this.value.indexOf(".")?new e(this.value):this.subtract(new e(.5)).round()},e.ceil=function(t){return-1===(t=e.validate(t)).indexOf(".")?t:e.round(e.add(t,.5))},e.prototype.ceil=function(){return-1===this.value.indexOf(".")?new e(this.value):this.add(new e(.5)).round()},e.add=function(t,n){return t=e.validate(t),n=e.validate(n),r.add(t,n)},e.prototype.add=function(t){return new e(r.add(this.value,t.getValue()))},e.subtract=function(t,n){return t=e.validate(t),n=e.validate(n),s.subtract(t,n)},e.prototype.subtract=function(t){return new e(s.subtract(this.value,t.getValue()))},e.multiply=function(t,n){return t=e.validate(t),n=e.validate(n),u.multiply(t,n)},e.prototype.multiply=function(t){return new e(u.multiply(this.value,t.getValue()))},e.divide=function(t,n,r){return t=e.validate(t),n=e.validate(n),o.divide(t,n,r)},e.prototype.divide=function(t,n){return new e(o.divide(this.value,t.getValue(),n))},e.compareTo=function(t,n){return t=e.validate(t),n=e.validate(n),a.compareTo(t,n)},e.prototype.compareTo=function(e){return a.compareTo(this.value,e.getValue())},e.negate=function(t){return t=e.validate(t),s.negate(t)},e.prototype.negate=function(){return new e(s.negate(this.value))},e.RoundingModes=l.RoundingModes,e}();e.exports=d}]); | ||
var bigDecimal=function(n){var r={};function i(e){if(r[e])return r[e].exports;var t=r[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}return i.m=n,i.c=r,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=3)}([function(e,t,n){"use strict";function o(e){for(var t="",n=e.length,r=e.split(".")[1],i=r?r.length:0,u=0;u<n;u++)"0"<=e[u]&&e[u]<="9"?t+=9-parseInt(e[u]):t+=e[u];return l(t,0<i?"0."+new Array(i).join("0")+"1":"1")}function a(e){var t=e.split(".");for(t[0]||(t[0]="0");"0"==t[0][0]&&1<t[0].length;)t[0]=t[0].substring(1);return t[0]+(t[1]?"."+t[1]:"")}function s(e,t){var n=e.split("."),r=t.split("."),i=n[0].length,u=r[0].length;return u<i?r[0]=new Array(Math.abs(i-u)+1).join("0")+(r[0]?r[0]:""):n[0]=new Array(Math.abs(i-u)+1).join("0")+(n[0]?n[0]:""),i=n[1]?n[1].length:0,u=r[1]?r[1].length:0,(i||u)&&(u<i?r[1]=(r[1]?r[1]:"")+new Array(Math.abs(i-u)+1).join("0"):n[1]=(n[1]?n[1]:"")+new Array(Math.abs(i-u)+1).join("0")),[e=n[0]+(n[1]?"."+n[1]:""),t=r[0]+(r[1]?"."+r[1]:"")]}function l(e,t){var n;e=(n=s(e,t))[0],t=n[1];for(var r="",i=0,u=e.length-1;0<=u;u--)if("."!==e[u]){var o=parseInt(e[u])+parseInt(t[u])+i;r=o%10+r,i=Math.floor(o/10)}else r="."+r;return i?i.toString()+r:r}Object.defineProperty(t,"__esModule",{value:!0}),t.add=function(e,t){var n;void 0===t&&(t="0");var r=0,i=-1;"-"==e[0]&&(r++,i=1,(e=e.substring(1)).length),"-"==t[0]&&(r++,i=2,(t=t.substring(1)).length),e=a(e),t=a(t),e=(n=s(a(e),a(t)))[0],t=n[1],1==r&&(1==i?e=o(e):t=o(t));var u=l(e,t);return r?2==r?"-"+a(u):e.length<u.length?a(u.substring(1)):"-"+a(o(u)):a(u)},t.trim=a,t.pad=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var d=n(2);function f(e,t,n,r){if(!e||e===new Array(e.length+1).join("0"))return!1;if(r===d.RoundingModes.DOWN||!n&&r===d.RoundingModes.FLOOR||n&&r===d.RoundingModes.CEILING)return!1;if(r===d.RoundingModes.UP||n&&r===d.RoundingModes.FLOOR||!n&&r===d.RoundingModes.CEILING)return!0;var i="5"+new Array(e.length).join("0");if(i<e)return!0;if(e<i)return!1;switch(r){case d.RoundingModes.HALF_DOWN:return!1;case d.RoundingModes.HALF_UP:return!0;case d.RoundingModes.HALF_EVEN:default:return parseInt(t[t.length-1])%2==1}}function g(e,t){void 0===t&&(t=0),t||(t=1),"number"==typeof e&&e.toString();for(var n="",r=e.length-1;0<=r;r--){var i=parseInt(e[r])+t;10==i?(t=1,i=0):t=0,n+=i}return t&&(n+=t),n.split("").reverse().join("")}t.roundOff=function e(t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=d.RoundingModes.HALF_EVEN),r===d.RoundingModes.UNNECESSARY)throw new Error("UNNECESSARY Rounding Mode has not yet been implemented");"number"==typeof t&&(t=t.toString());var i=!1;"-"===t[0]&&(i=!0,t=t.substring(1));var u=t.split("."),o=u[0],a=u[1];if(n<0){if(n=-n,o.length<=n)return"0";var s=o.substr(0,o.length-n);return(i?"-":"")+(s=e(t=s+"."+o.substr(o.length-n)+a,0,r))+new Array(n+1).join("0")}if(0==n)return o.length,f(u[1],o,i,r)?(i?"-":"")+g(o):(i?"-":"")+o;if(!u[1])return(i?"-":"")+o+"."+new Array(n+1).join("0");if(u[1].length<n)return(i?"-":"")+o+"."+u[1]+new Array(n-u[1].length+1).join("0");a=u[1].substring(0,n);var l=u[1].substring(n);return l&&f(l,a,i,r)&&(a=g(a)).length>n?g(o,parseInt(a[0]))+"."+a.substring(1):(i?"-":"")+o+"."+a}},function(e,t,n){"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),(r=t.RoundingModes||(t.RoundingModes={}))[r.CEILING=0]="CEILING",r[r.DOWN=1]="DOWN",r[r.FLOOR=2]="FLOOR",r[r.HALF_DOWN=3]="HALF_DOWN",r[r.HALF_EVEN=4]="HALF_EVEN",r[r.HALF_UP=5]="HALF_UP",r[r.UNNECESSARY=6]="UNNECESSARY",r[r.UP=7]="UP"},function(e,t,n){"use strict";var i=n(0),r=n(1),u=n(4),o=n(5),a=n(6),s=n(7),l=n(2),d=(f.validate=function(e){if(e){if(e=e.toString(),isNaN(e))throw Error("Parameter is not a number: "+e);"+"==e[0]&&(e=e.substring(1))}else e="0";if(/e/i.test(e)){var t=e.split(/[eE]/),n=t[0],r=t[1];n=i.trim(n),r=parseInt(r)+n.indexOf("."),e=(n=n.replace(".","")).length<r?n+new Array(r-n.length+1).join("0"):n.length>=r&&0<r?i.trim(n.substring(0,r))+(n.length>r?"."+n.substring(r):""):"0."+new Array(1-r).join("0")+n}return e},f.prototype.getValue=function(){return this.value},f.getPrettyValue=function(e,t,n){if(t||n){if(!t||!n)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else t=3,n=",";var r="-"==(e=f.validate(e)).charAt(0);r&&(e=e.substring(1));for(var i=e.indexOf("."),u="",o=i=0<i?i:e.length;0<o;)o<t?(t=o,o=0):o-=t,u=e.substring(o,o+t)+(o<i-t&&0<=o?n:"")+u;return(r?"-":"")+u+e.substring(i)},f.prototype.getPrettyValue=function(e,t){return f.getPrettyValue(this.value,e,t)},f.round=function(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n=l.RoundingModes.HALF_EVEN),e=f.validate(e),isNaN(t))throw Error("Precision is not a number: "+t);return r.roundOff(e,t,n)},f.prototype.round=function(e,t){if(void 0===e&&(e=0),void 0===t&&(t=l.RoundingModes.HALF_EVEN),isNaN(e))throw Error("Precision is not a number: "+e);return new f(r.roundOff(this.value,e,t))},f.floor=function(e){return-1===(e=f.validate(e)).indexOf(".")?e:f.round(f.subtract(e,.5))},f.prototype.floor=function(){return-1===this.value.indexOf(".")?new f(this.value):this.subtract(new f(.5)).round()},f.ceil=function(e){return-1===(e=f.validate(e)).indexOf(".")?e:f.round(f.add(e,.5))},f.prototype.ceil=function(){return-1===this.value.indexOf(".")?new f(this.value):this.add(new f(.5)).round()},f.add=function(e,t){return e=f.validate(e),t=f.validate(t),i.add(e,t)},f.prototype.add=function(e){return new f(i.add(this.value,e.getValue()))},f.subtract=function(e,t){return e=f.validate(e),t=f.validate(t),s.subtract(e,t)},f.prototype.subtract=function(e){return new f(s.subtract(this.value,e.getValue()))},f.multiply=function(e,t){return e=f.validate(e),t=f.validate(t),u.multiply(e,t)},f.prototype.multiply=function(e){return new f(u.multiply(this.value,e.getValue()))},f.divide=function(e,t,n){return e=f.validate(e),t=f.validate(t),o.divide(e,t,n)},f.prototype.divide=function(e,t){return new f(o.divide(this.value,e.getValue(),t))},f.compareTo=function(e,t){return e=f.validate(e),t=f.validate(t),a.compareTo(e,t)},f.prototype.compareTo=function(e){return a.compareTo(this.value,e.getValue())},f.negate=function(e){return e=f.validate(e),s.negate(e)},f.prototype.negate=function(){return new f(s.negate(this.value))},f.RoundingModes=l.RoundingModes,f);function f(e){void 0===e&&(e="0"),this.value=f.validate(e)}e.exports=d},function(e,t,n){"use strict";function p(e){for(;"0"==e[0];)e=e.substr(1);if(-1!=e.indexOf("."))for(;"0"==e[e.length-1];)e=e.substr(0,e.length-1);return""==e||"."==e?e="0":"."==e[e.length-1]&&(e=e.substr(0,e.length-1)),"."==e[0]&&(e="0"+e),e}Object.defineProperty(t,"__esModule",{value:!0}),t.multiply=function(e,t){e=e.toString(),t=t.toString();var n=0;"-"==e[0]&&(n++,e=e.substr(1)),"-"==t[0]&&(n++,t=t.substr(1)),e=p(e),t=p(t);var r=0,i=0;-1!=e.indexOf(".")&&(r=e.length-e.indexOf(".")-1),-1!=t.indexOf(".")&&(i=t.length-t.indexOf(".")-1);var u=r+i;if(e=p(e.replace(".","")),t=p(t.replace(".","")),e.length<t.length){var o=e;e=t,t=o}if("0"==t)return"0";for(var a=t.length,s=0,l=[],d=a-1,f="",g=0;g<a;g++)l[g]=e.length-1;for(g=0;g<2*e.length;g++){for(var c=0,v=t.length-1;d<=v&&0<=v;v--)-1<l[v]&&l[v]<e.length&&(c+=parseInt(e[l[v]--])*parseInt(t[v]));c+=s,s=Math.floor(c/10),f=c%10+f,d--}return f=p(function(e,t){return 0==t?e:(e=t>=e.length?new Array(t-e.length+1).join("0")+e:e).substr(0,e.length-t)+"."+e.substr(e.length-t,t)}(f,u)),1==n&&(f="-"+f),f}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var c=n(0),v=n(1);t.divide=function(e,t,n){if(void 0===n&&(n=8),0==t)throw new Error("Cannot divide by 0");if(e=e.toString(),t=t.toString(),e=e.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),t=t.replace(/(\.\d*?[1-9])0+$/g,"$1").replace(/\.0+$/,""),0==e)return"0";var r=0;"-"==t[0]&&(t=t.substring(1),r++),"-"==e[0]&&(e=e.substring(1),r++);var i=0<t.indexOf(".")?t.length-t.indexOf(".")-1:-1;if(t=c.trim(t.replace(".","")),0<=i){var u=0<e.indexOf(".")?e.length-e.indexOf(".")-1:-1;if(-1==u)e=c.trim(e+new Array(1+i).join("0"));else if(u<i)e=e.replace(".",""),e=c.trim(e+new Array(i-u+1).join("0"));else if(i<u){var o=(e=e.replace(".","")).length-u+i;e=c.trim(e.substring(0,o)+"."+e.substring(o))}else i==u&&(e=c.trim(e.replace(".","")))}var a=0,s=t.length,l="",d=-1<e.indexOf(".")&&e.indexOf(".")<s?e.substring(0,s+1):e.substring(0,s);if(e=-1<e.indexOf(".")&&e.indexOf(".")<s?e.substring(s+1):e.substring(s),-1<d.indexOf(".")){var f=d.length-d.indexOf(".")-1;s>(d=d.replace(".","")).length&&(f+=s-d.length,d+=new Array(s-d.length+1).join("0")),a=f,l="0."+new Array(f).join("0")}for(n+=2;a<=n;){for(var g=0;parseInt(d)>=parseInt(t);)d=c.add(d,"-"+t),g++;l+=g,e?("."==e[0]&&(l+=".",a++,e=e.substring(1)),d+=e.substring(0,1),e=e.substring(1)):(a||(l+="."),a++,d+="0")}return(1==r?"-":"")+c.trim(v.roundOff(l,n-2))}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var u=n(0);t.compareTo=function(e,t){var n,r=!1;if("-"==e[0]&&"-"!=t[0])return-1;if("-"!=e[0]&&"-"==t[0])return 1;if("-"==e[0]&&"-"==t[0]&&(e=e.substr(1),t=t.substr(1),r=!0),e=(n=u.pad(e,t))[0],t=n[1],0==e.localeCompare(t))return 0;for(var i=0;i<e.length;i++)if(e[i]!=t[i])return e[i]>t[i]?r?-1:1:r?1:-1;return 0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);function i(e){return e="-"==e[0]?e.substr(1):"-"+e}t.subtract=function(e,t){return e=e.toString(),t=i(t=t.toString()),r.add(e,t)},t.negate=i}]); |
{ | ||
"name": "js-big-decimal", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Work with large numbers on the client side. Round them off to any required precission.", | ||
@@ -11,3 +11,3 @@ "main": "dist/node/js-big-decimal", | ||
"pretravis-test": "tsc", | ||
"travis-test": "jasmine-ts JASMINE_CONFIG_PATH=spec/jasmine.json", | ||
"travis-test": "cross-env JASMINE_CONFIG_PATH=spec/jasmine.json jasmine-ts", | ||
"test-random": "node test/randomtest.js", | ||
@@ -50,15 +50,21 @@ "compile": "tsc", | ||
"devDependencies": { | ||
"@types/jasmine": "^2.8.7", | ||
"@types/node": "^10.1.1", | ||
"del": "^3.0.0", | ||
"glob": "^7.1.2", | ||
"gulp": "^3.9.1", | ||
"@types/jasmine": "^3.3.12", | ||
"@types/node": "^12.0.0", | ||
"chokidar-cli": "^1.2.2", | ||
"cross-env": "^5.2.0", | ||
"del": "^4.1.1", | ||
"glob": "^7.1.3", | ||
"gulp": "^4.0.1", | ||
"gulp-run": "^1.7.1", | ||
"jasmine": "^3.4.0", | ||
"jasmine-spec-reporter": "^4.2.1", | ||
"jasmine-ts": "^0.2.1", | ||
"uglifyjs-webpack-plugin": "^1.2.5", | ||
"webpack": "^4.8.3", | ||
"webpack-cli": "^2.1.3" | ||
"jasmine-ts": "^0.3.0", | ||
"ts-node": "^8.1.0", | ||
"typescript": "^3.4.5", | ||
"uglifyjs-webpack-plugin": "^2.1.2", | ||
"webpack": "^4.30.0", | ||
"webpack-cli": "^3.3.2" | ||
}, | ||
"false": {} | ||
"false": {}, | ||
"dependencies": {} | ||
} |
@@ -0,0 +0,0 @@ # JS Big Decimal |
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
1637
262830
16