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

js-big-decimal

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-big-decimal - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

2

dist/node/big-decimal.d.ts

@@ -8,3 +8,3 @@ declare class bigDecimal {

getPrettyValue(digits: any, separator: any): string;
static round(number: any, precision: any): any;
static round(number: any, precision: any): string;
round(precision: any): bigDecimal;

@@ -11,0 +11,0 @@ static add(number1: any, number2: any): string;

@@ -197,3 +197,15 @@ (function webpackUniversalModuleDefinition(root, factory) {

input = input.toString();
var parts = input.split('.'), partInt = parts[0];
var parts = input.split('.'), partInt = parts[0], partDec = parts[1];
//handle case of -ve input
if (n < 0) {
n = -n;
if (partInt.length <= n)
return '0';
else {
var prefix = partInt.substr(0, partInt.length - n);
input = prefix + '.' + partInt.substr(partInt.length - n) + partDec;
prefix = roundOff(input);
return prefix + (new Array(n + 1).join('0'));
}
}
if (n == 0) {

@@ -212,3 +224,4 @@ var l = partInt.length;

}
var partDec = parts[1].substring(0, n), rem = parts[1].substring(n);
partDec = parts[1].substring(0, n);
var rem = parts[1].substring(n);
if (rem && greaterThanFive(rem, partDec)) {

@@ -215,0 +228,0 @@ partDec = increment(partDec);

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.bigDecimal=e():t.bigDecimal=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=2)}([function(t,e,r){"use strict";function n(t,e){void 0===e&&(e="0");var r=0,n=-1;"-"==t[0]&&(r++,n=1,t=t.substring(1),t.length),"-"==e[0]&&(r++,n=2,e=e.substring(1),e.length),t=u(t),e=u(e),l=o(u(t),u(e)),t=l[0],e=l[1],1==r&&(1==n?t=i(t):e=i(e));var s=a(t,e);return r?2==r?"-"+u(s):t.length<s.length?u(s.substring(1)):"-"+u(i(s)):u(s);var l}function i(t){for(var e="",r=t.length,n=t.split(".")[1],i=n?n.length:0,u=0;u<r;u++)t[u]>="0"&&t[u]<="9"?e+=9-parseInt(t[u]):e+=t[u];return a(e,i>0?"0."+new Array(i).join("0")+"1":"1")}function u(t){var e=t.split(".");for(e[0]||(e[0]="0");"0"==e[0][0]&&e[0].length>1;)e[0]=e[0].substring(1);return e[0]+(e[1]?"."+e[1]:"")}function o(t,e){var r=t.split("."),n=e.split("."),i=r[0].length,u=n[0].length;return i>u?n[0]=new Array(Math.abs(i-u)+1).join("0")+(n[0]?n[0]:""):r[0]=new Array(Math.abs(i-u)+1).join("0")+(r[0]?r[0]:""),i=r[1]?r[1].length:0,u=n[1]?n[1].length:0,(i||u)&&(i>u?n[1]=(n[1]?n[1]:"")+new Array(Math.abs(i-u)+1).join("0"):r[1]=(r[1]?r[1]:"")+new Array(Math.abs(i-u)+1).join("0")),t=r[0]+(r[1]?"."+r[1]:""),e=n[0]+(n[1]?"."+n[1]:""),[t,e]}function a(t,e){a=o(t,e),t=a[0],e=a[1];for(var r="",n=0,i=t.length-1;i>=0;i--)if("."!==t[i]){var u=parseInt(t[i])+parseInt(e[i])+n;r=u%10+r,n=Math.floor(u/10)}else r="."+r;return n?n.toString()+r:r;var a}Object.defineProperty(e,"__esModule",{value:!0}),e.add=n,e.trim=u,e.pad=o},function(t,e,r){"use strict";function n(t,e){void 0===e&&(e=0),"number"==typeof t&&(t=t.toString());var r=t.split("."),n=r[0];if(0==e){n.length;return i(r[1],n)?u(n):n}if(!r[1])return n+"."+new Array(e+1).join("0");if(r[1].length<e)return n+"."+r[1]+new Array(e-r[1].length+1).join("0");var o=r[1].substring(0,e),a=r[1].substring(e);return a&&i(a,o)&&(o=u(o),o.length>e)?u(n,parseInt(o[0]))+"."+o.substring(1):n+"."+o}function i(t,e){return!!t&&(t>"5"+new Array(t.length+1).join("0")||"5"==t&&parseInt(e[e.length-1])%2==1)}function u(t,e){void 0===e&&(e=0),e||(e=1),"number"==typeof t&&t.toString();for(var r=t.length-1,n="",i=r;i>=0;i--){var u=parseInt(t[i])+e;10==u?(e=1,u=0):e=0,n+=u}return e&&(n+=e),n.split("").reverse().join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.roundOff=n},function(t,e,r){"use strict";var n=r(0),i=r(1),u=r(3),o=r(4),a=r(5),s=r(6),l=function(){function t(e){void 0===e&&(e="0"),this.value=t.validate(e)}return t.validate=function(t){if(t){if(t=t.toString(),isNaN(t))throw Error("Parameter is not a number: "+t);"+"==t[0]&&(t=t.substring(1))}else t="0";if(/e/i.test(t)){var e=t.split(/[eE]/),r=e[0],i=e[1];r=n.trim(r),i=parseInt(i)+r.indexOf("."),r=r.replace(".",""),t=r.length<i?r+new Array(i-r.length+1).join("0"):r.length>=i&&i>0?n.trim(r.substring(0,i))+(r.length>i?"."+r.substring(i):""):"0."+new Array(1-i).join("0")+r}return t},t.prototype.getValue=function(){return this.value},t.getPrettyValue=function(e,r,n){if(r||n){if(!r||!n)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else r=3,n=",";e=t.validate(e);var i="-"==e.charAt(0);i&&(e=e.substring(1));var u=e.indexOf(".");u=u>0?u:e.length;for(var o="",a=u;a>0;)a<r?(r=a,a=0):a-=r,o=e.substring(a,a+r)+(a<u-r&&a>=0?n:"")+o;return(i?"-":"")+o+e.substring(u)},t.prototype.getPrettyValue=function(e,r){return t.getPrettyValue(this.value,e,r)},t.round=function(e,r){if(e=t.validate(e),r){if(isNaN(r))throw Error("Precision is not a number: "+r)}else r=0;return i.roundOff(e,r)},t.prototype.round=function(e){if(e){if(isNaN(e))throw Error("Precision is not a number: "+e)}else e=0;return new t(i.roundOff(this.value,e))},t.add=function(e,r){return e=t.validate(e),r=t.validate(r),n.add(e,r)},t.prototype.add=function(e){return new t(n.add(this.value,e.getValue()))},t.subtract=function(e,r){return e=t.validate(e),r=t.validate(r),s.subtract(e,r)},t.prototype.subtract=function(e){return new t(s.subtract(this.value,e.getValue()))},t.multiply=function(e,r){return e=t.validate(e),r=t.validate(r),u.multiply(e,r)},t.prototype.multiply=function(e){return new t(u.multiply(this.value,e.getValue()))},t.divide=function(e,r,n){return e=t.validate(e),r=t.validate(r),o.divide(e,r,n)},t.prototype.divide=function(e,r){return new t(o.divide(this.value,e.getValue(),r))},t.compareTo=function(e,r){return e=t.validate(e),r=t.validate(r),a.compareTo(e,r)},t.prototype.compareTo=function(t){return a.compareTo(this.value,t.getValue())},t.negate=function(e){return e=t.validate(e),s.negate(e)},t.prototype.negate=function(){return new t(s.negate(this.value))},t}();t.exports=l},function(t,e,r){"use strict";function n(t,e){t=t.toString(),e=e.toString();var r=0;"-"==t[0]&&(r++,t=t.substr(1)),"-"==e[0]&&(r++,e=e.substr(1)),t=u(t),e=u(e);var n=0,o=0;-1!=t.indexOf(".")&&(n=t.length-t.indexOf(".")-1),-1!=e.indexOf(".")&&(o=e.length-e.indexOf(".")-1);var a=n+o;if(t=u(t.replace(".","")),e=u(e.replace(".","")),t.length<e.length){var s=t;t=e,e=s}if("0"==e)return"0";for(var l=e.length,f=0,g=[],c=l-1,d="",p=0;p<l;p++)g[p]=t.length-1;for(var p=0;p<2*t.length;p++){for(var v=0,h=e.length-1;h>=c&&h>=0;h--)g[h]>-1&&g[h]<t.length&&(v+=parseInt(t[g[h]--])*parseInt(e[h]));v+=f,f=Math.floor(v/10),d=v%10+d,c--}return d=u(i(d,a)),1==r&&(d="-"+d),d}function i(t,e){return 0==e?t:(t=e>=t.length?new Array(e-t.length+1).join("0")+t:t,t.substr(0,t.length-e)+"."+t.substr(t.length-e,e))}function u(t){for(;"0"==t[0];)t=t.substr(1);if(-1!=t.indexOf("."))for(;"0"==t[t.length-1];)t=t.substr(0,t.length-1);return""==t||"."==t?t="0":"."==t[t.length-1]&&(t=t.substr(0,t.length-1)),"."==t[0]&&(t="0"+t),t}Object.defineProperty(e,"__esModule",{value:!0}),e.multiply=n},function(t,e,r){"use strict";function n(t,e,r){if(void 0===r&&(r=8),0==e)throw new Error("Cannot divide by 0");if(t=t.toString(),e=e.toString(),0==t)return"0";var n=0;"-"==e[0]&&(e=e.substring(1),n++),"-"==t[0]&&(t=t.substring(1),n++);var o=e.indexOf(".")>0?e.length-e.indexOf(".")-1:-1;if(e=i.trim(e.replace(".","")),o>=0){var a=t.indexOf(".")>0?t.length-t.indexOf(".")-1:-1;if(-1==a)t=i.trim(t+new Array(o+1).join("0"));else if(o>a)t=t.replace(".",""),t=i.trim(t+new Array(o-a+1).join("0"));else if(o<a){t=t.replace(".","");var s=t.length-o+o;t=i.trim(t.substring(0,s)+"."+t.substring(s))}else o==a&&(t=i.trim(t.replace(".","")))}var l=0,f=e.length,g="",c=t.indexOf(".")>-1&&t.indexOf(".")<f?t.substring(0,f+1):t.substring(0,f);if(t=t.indexOf(".")>-1&&t.indexOf(".")<f?t.substring(f+1):t.substring(f),c.indexOf(".")>-1){var d=c.length-c.indexOf(".")-1;c=c.replace(".",""),f>c.length&&(d+=f-c.length,c+=new Array(f-c.length+1).join("0")),l=d,g="0."+new Array(d).join("0")}for(r+=2;l<=r;){for(var p=0;parseInt(c)>=parseInt(e);)c=i.add(c,"-"+e),p++;g+=p,t?("."==t[0]&&(g+=".",l++,t=t.substring(1)),c+=t.substring(0,1),t=t.substring(1)):(l||(g+="."),l++,c+="0")}return(1==n?"-":"")+i.trim(u.roundOff(g,r-2))}Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),u=r(1);e.divide=n},function(t,e,r){"use strict";function n(t,e){var r=!1;if("-"==t[0]&&"-"!=e[0])return-1;if("-"!=t[0]&&"-"==e[0])return 1;if("-"==t[0]&&"-"==e[0]&&(t=t.substr(1),e=e.substr(1),r=!0),u=i.pad(t,e),t=u[0],e=u[1],0==t.localeCompare(e))return 0;for(var n=0;n<t.length;n++)if(t[n]!=e[n])return t[n]>e[n]?r?-1:1:r?1:-1;return 0;var u}Object.defineProperty(e,"__esModule",{value:!0});var i=r(0);e.compareTo=n},function(t,e,r){"use strict";function n(t,e){return t=t.toString(),e=e.toString(),e=i(e),u.add(t,e)}function i(t){return t="-"==t[0]?t.substr(1):"-"+t}Object.defineProperty(e,"__esModule",{value:!0});var u=r(0);e.subtract=n,e.negate=i}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.bigDecimal=e():t.bigDecimal=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=2)}([function(t,e,r){"use strict";function n(t,e){void 0===e&&(e="0");var r=0,n=-1;"-"==t[0]&&(r++,n=1,t=t.substring(1),t.length),"-"==e[0]&&(r++,n=2,e=e.substring(1),e.length),t=u(t),e=u(e),l=o(u(t),u(e)),t=l[0],e=l[1],1==r&&(1==n?t=i(t):e=i(e));var s=a(t,e);return r?2==r?"-"+u(s):t.length<s.length?u(s.substring(1)):"-"+u(i(s)):u(s);var l}function i(t){for(var e="",r=t.length,n=t.split(".")[1],i=n?n.length:0,u=0;u<r;u++)t[u]>="0"&&t[u]<="9"?e+=9-parseInt(t[u]):e+=t[u];return a(e,i>0?"0."+new Array(i).join("0")+"1":"1")}function u(t){var e=t.split(".");for(e[0]||(e[0]="0");"0"==e[0][0]&&e[0].length>1;)e[0]=e[0].substring(1);return e[0]+(e[1]?"."+e[1]:"")}function o(t,e){var r=t.split("."),n=e.split("."),i=r[0].length,u=n[0].length;return i>u?n[0]=new Array(Math.abs(i-u)+1).join("0")+(n[0]?n[0]:""):r[0]=new Array(Math.abs(i-u)+1).join("0")+(r[0]?r[0]:""),i=r[1]?r[1].length:0,u=n[1]?n[1].length:0,(i||u)&&(i>u?n[1]=(n[1]?n[1]:"")+new Array(Math.abs(i-u)+1).join("0"):r[1]=(r[1]?r[1]:"")+new Array(Math.abs(i-u)+1).join("0")),t=r[0]+(r[1]?"."+r[1]:""),e=n[0]+(n[1]?"."+n[1]:""),[t,e]}function a(t,e){a=o(t,e),t=a[0],e=a[1];for(var r="",n=0,i=t.length-1;i>=0;i--)if("."!==t[i]){var u=parseInt(t[i])+parseInt(e[i])+n;r=u%10+r,n=Math.floor(u/10)}else r="."+r;return n?n.toString()+r:r;var a}Object.defineProperty(e,"__esModule",{value:!0}),e.add=n,e.trim=u,e.pad=o},function(t,e,r){"use strict";function n(t,e){void 0===e&&(e=0),"number"==typeof t&&(t=t.toString());var r=t.split("."),o=r[0],a=r[1];if(e<0){if(e=-e,o.length<=e)return"0";var s=o.substr(0,o.length-e);return t=s+"."+o.substr(o.length-e)+a,(s=n(t))+new Array(e+1).join("0")}if(0==e){o.length;return i(r[1],o)?u(o):o}if(!r[1])return o+"."+new Array(e+1).join("0");if(r[1].length<e)return o+"."+r[1]+new Array(e-r[1].length+1).join("0");a=r[1].substring(0,e);var l=r[1].substring(e);return l&&i(l,a)&&(a=u(a),a.length>e)?u(o,parseInt(a[0]))+"."+a.substring(1):o+"."+a}function i(t,e){return!!t&&(t>"5"+new Array(t.length+1).join("0")||"5"==t&&parseInt(e[e.length-1])%2==1)}function u(t,e){void 0===e&&(e=0),e||(e=1),"number"==typeof t&&t.toString();for(var r=t.length-1,n="",i=r;i>=0;i--){var u=parseInt(t[i])+e;10==u?(e=1,u=0):e=0,n+=u}return e&&(n+=e),n.split("").reverse().join("")}Object.defineProperty(e,"__esModule",{value:!0}),e.roundOff=n},function(t,e,r){"use strict";var n=r(0),i=r(1),u=r(3),o=r(4),a=r(5),s=r(6),l=function(){function t(e){void 0===e&&(e="0"),this.value=t.validate(e)}return t.validate=function(t){if(t){if(t=t.toString(),isNaN(t))throw Error("Parameter is not a number: "+t);"+"==t[0]&&(t=t.substring(1))}else t="0";if(/e/i.test(t)){var e=t.split(/[eE]/),r=e[0],i=e[1];r=n.trim(r),i=parseInt(i)+r.indexOf("."),r=r.replace(".",""),t=r.length<i?r+new Array(i-r.length+1).join("0"):r.length>=i&&i>0?n.trim(r.substring(0,i))+(r.length>i?"."+r.substring(i):""):"0."+new Array(1-i).join("0")+r}return t},t.prototype.getValue=function(){return this.value},t.getPrettyValue=function(e,r,n){if(r||n){if(!r||!n)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else r=3,n=",";e=t.validate(e);var i="-"==e.charAt(0);i&&(e=e.substring(1));var u=e.indexOf(".");u=u>0?u:e.length;for(var o="",a=u;a>0;)a<r?(r=a,a=0):a-=r,o=e.substring(a,a+r)+(a<u-r&&a>=0?n:"")+o;return(i?"-":"")+o+e.substring(u)},t.prototype.getPrettyValue=function(e,r){return t.getPrettyValue(this.value,e,r)},t.round=function(e,r){if(e=t.validate(e),r){if(isNaN(r))throw Error("Precision is not a number: "+r)}else r=0;return i.roundOff(e,r)},t.prototype.round=function(e){if(e){if(isNaN(e))throw Error("Precision is not a number: "+e)}else e=0;return new t(i.roundOff(this.value,e))},t.add=function(e,r){return e=t.validate(e),r=t.validate(r),n.add(e,r)},t.prototype.add=function(e){return new t(n.add(this.value,e.getValue()))},t.subtract=function(e,r){return e=t.validate(e),r=t.validate(r),s.subtract(e,r)},t.prototype.subtract=function(e){return new t(s.subtract(this.value,e.getValue()))},t.multiply=function(e,r){return e=t.validate(e),r=t.validate(r),u.multiply(e,r)},t.prototype.multiply=function(e){return new t(u.multiply(this.value,e.getValue()))},t.divide=function(e,r,n){return e=t.validate(e),r=t.validate(r),o.divide(e,r,n)},t.prototype.divide=function(e,r){return new t(o.divide(this.value,e.getValue(),r))},t.compareTo=function(e,r){return e=t.validate(e),r=t.validate(r),a.compareTo(e,r)},t.prototype.compareTo=function(t){return a.compareTo(this.value,t.getValue())},t.negate=function(e){return e=t.validate(e),s.negate(e)},t.prototype.negate=function(){return new t(s.negate(this.value))},t}();t.exports=l},function(t,e,r){"use strict";function n(t,e){t=t.toString(),e=e.toString();var r=0;"-"==t[0]&&(r++,t=t.substr(1)),"-"==e[0]&&(r++,e=e.substr(1)),t=u(t),e=u(e);var n=0,o=0;-1!=t.indexOf(".")&&(n=t.length-t.indexOf(".")-1),-1!=e.indexOf(".")&&(o=e.length-e.indexOf(".")-1);var a=n+o;if(t=u(t.replace(".","")),e=u(e.replace(".","")),t.length<e.length){var s=t;t=e,e=s}if("0"==e)return"0";for(var l=e.length,f=0,g=[],c=l-1,d="",p=0;p<l;p++)g[p]=t.length-1;for(var p=0;p<2*t.length;p++){for(var v=0,h=e.length-1;h>=c&&h>=0;h--)g[h]>-1&&g[h]<t.length&&(v+=parseInt(t[g[h]--])*parseInt(e[h]));v+=f,f=Math.floor(v/10),d=v%10+d,c--}return d=u(i(d,a)),1==r&&(d="-"+d),d}function i(t,e){return 0==e?t:(t=e>=t.length?new Array(e-t.length+1).join("0")+t:t,t.substr(0,t.length-e)+"."+t.substr(t.length-e,e))}function u(t){for(;"0"==t[0];)t=t.substr(1);if(-1!=t.indexOf("."))for(;"0"==t[t.length-1];)t=t.substr(0,t.length-1);return""==t||"."==t?t="0":"."==t[t.length-1]&&(t=t.substr(0,t.length-1)),"."==t[0]&&(t="0"+t),t}Object.defineProperty(e,"__esModule",{value:!0}),e.multiply=n},function(t,e,r){"use strict";function n(t,e,r){if(void 0===r&&(r=8),0==e)throw new Error("Cannot divide by 0");if(t=t.toString(),e=e.toString(),0==t)return"0";var n=0;"-"==e[0]&&(e=e.substring(1),n++),"-"==t[0]&&(t=t.substring(1),n++);var o=e.indexOf(".")>0?e.length-e.indexOf(".")-1:-1;if(e=i.trim(e.replace(".","")),o>=0){var a=t.indexOf(".")>0?t.length-t.indexOf(".")-1:-1;if(-1==a)t=i.trim(t+new Array(o+1).join("0"));else if(o>a)t=t.replace(".",""),t=i.trim(t+new Array(o-a+1).join("0"));else if(o<a){t=t.replace(".","");var s=t.length-o+o;t=i.trim(t.substring(0,s)+"."+t.substring(s))}else o==a&&(t=i.trim(t.replace(".","")))}var l=0,f=e.length,g="",c=t.indexOf(".")>-1&&t.indexOf(".")<f?t.substring(0,f+1):t.substring(0,f);if(t=t.indexOf(".")>-1&&t.indexOf(".")<f?t.substring(f+1):t.substring(f),c.indexOf(".")>-1){var d=c.length-c.indexOf(".")-1;c=c.replace(".",""),f>c.length&&(d+=f-c.length,c+=new Array(f-c.length+1).join("0")),l=d,g="0."+new Array(d).join("0")}for(r+=2;l<=r;){for(var p=0;parseInt(c)>=parseInt(e);)c=i.add(c,"-"+e),p++;g+=p,t?("."==t[0]&&(g+=".",l++,t=t.substring(1)),c+=t.substring(0,1),t=t.substring(1)):(l||(g+="."),l++,c+="0")}return(1==n?"-":"")+i.trim(u.roundOff(g,r-2))}Object.defineProperty(e,"__esModule",{value:!0});var i=r(0),u=r(1);e.divide=n},function(t,e,r){"use strict";function n(t,e){var r=!1;if("-"==t[0]&&"-"!=e[0])return-1;if("-"!=t[0]&&"-"==e[0])return 1;if("-"==t[0]&&"-"==e[0]&&(t=t.substr(1),e=e.substr(1),r=!0),u=i.pad(t,e),t=u[0],e=u[1],0==t.localeCompare(e))return 0;for(var n=0;n<t.length;n++)if(t[n]!=e[n])return t[n]>e[n]?r?-1:1:r?1:-1;return 0;var u}Object.defineProperty(e,"__esModule",{value:!0});var i=r(0);e.compareTo=n},function(t,e,r){"use strict";function n(t,e){return t=t.toString(),e=e.toString(),e=i(e),u.add(t,e)}function i(t){return t="-"==t[0]?t.substr(1):"-"+t}Object.defineProperty(e,"__esModule",{value:!0});var u=r(0);e.subtract=n,e.negate=i}])});

@@ -188,3 +188,15 @@ var bigDecimal =

input = input.toString();
var parts = input.split('.'), partInt = parts[0];
var parts = input.split('.'), partInt = parts[0], partDec = parts[1];
//handle case of -ve input
if (n < 0) {
n = -n;
if (partInt.length <= n)
return '0';
else {
var prefix = partInt.substr(0, partInt.length - n);
input = prefix + '.' + partInt.substr(partInt.length - n) + partDec;
prefix = roundOff(input);
return prefix + (new Array(n + 1).join('0'));
}
}
if (n == 0) {

@@ -203,3 +215,4 @@ var l = partInt.length;

}
var partDec = parts[1].substring(0, n), rem = parts[1].substring(n);
partDec = parts[1].substring(0, n);
var rem = parts[1].substring(n);
if (rem && greaterThanFive(rem, partDec)) {

@@ -206,0 +219,0 @@ partDec = increment(partDec);

@@ -1,1 +0,1 @@

var bigDecimal=function(t){function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}var e={};return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},r.p="",r(r.s=2)}([function(t,r,e){"use strict";function n(t,r){void 0===r&&(r="0");var e=0,n=-1;"-"==t[0]&&(e++,n=1,t=t.substring(1),t.length),"-"==r[0]&&(e++,n=2,r=r.substring(1),r.length),t=u(t),r=u(r),l=a(u(t),u(r)),t=l[0],r=l[1],1==e&&(1==n?t=i(t):r=i(r));var s=o(t,r);return e?2==e?"-"+u(s):t.length<s.length?u(s.substring(1)):"-"+u(i(s)):u(s);var l}function i(t){for(var r="",e=t.length,n=t.split(".")[1],i=n?n.length:0,u=0;u<e;u++)t[u]>="0"&&t[u]<="9"?r+=9-parseInt(t[u]):r+=t[u];return o(r,i>0?"0."+new Array(i).join("0")+"1":"1")}function u(t){var r=t.split(".");for(r[0]||(r[0]="0");"0"==r[0][0]&&r[0].length>1;)r[0]=r[0].substring(1);return r[0]+(r[1]?"."+r[1]:"")}function a(t,r){var e=t.split("."),n=r.split("."),i=e[0].length,u=n[0].length;return i>u?n[0]=new Array(Math.abs(i-u)+1).join("0")+(n[0]?n[0]:""):e[0]=new Array(Math.abs(i-u)+1).join("0")+(e[0]?e[0]:""),i=e[1]?e[1].length:0,u=n[1]?n[1].length:0,(i||u)&&(i>u?n[1]=(n[1]?n[1]:"")+new Array(Math.abs(i-u)+1).join("0"):e[1]=(e[1]?e[1]:"")+new Array(Math.abs(i-u)+1).join("0")),t=e[0]+(e[1]?"."+e[1]:""),r=n[0]+(n[1]?"."+n[1]:""),[t,r]}function o(t,r){o=a(t,r),t=o[0],r=o[1];for(var e="",n=0,i=t.length-1;i>=0;i--)if("."!==t[i]){var u=parseInt(t[i])+parseInt(r[i])+n;e=u%10+e,n=Math.floor(u/10)}else e="."+e;return n?n.toString()+e:e;var o}Object.defineProperty(r,"__esModule",{value:!0}),r.add=n,r.trim=u,r.pad=a},function(t,r,e){"use strict";function n(t,r){void 0===r&&(r=0),"number"==typeof t&&(t=t.toString());var e=t.split("."),n=e[0];if(0==r){n.length;return i(e[1],n)?u(n):n}if(!e[1])return n+"."+new Array(r+1).join("0");if(e[1].length<r)return n+"."+e[1]+new Array(r-e[1].length+1).join("0");var a=e[1].substring(0,r),o=e[1].substring(r);return o&&i(o,a)&&(a=u(a),a.length>r)?u(n,parseInt(a[0]))+"."+a.substring(1):n+"."+a}function i(t,r){return!!t&&(t>"5"+new Array(t.length+1).join("0")||"5"==t&&parseInt(r[r.length-1])%2==1)}function u(t,r){void 0===r&&(r=0),r||(r=1),"number"==typeof t&&t.toString();for(var e=t.length-1,n="",i=e;i>=0;i--){var u=parseInt(t[i])+r;10==u?(r=1,u=0):r=0,n+=u}return r&&(n+=r),n.split("").reverse().join("")}Object.defineProperty(r,"__esModule",{value:!0}),r.roundOff=n},function(t,r,e){"use strict";var n=e(0),i=e(1),u=e(3),a=e(4),o=e(5),s=e(6),l=function(){function t(r){void 0===r&&(r="0"),this.value=t.validate(r)}return t.validate=function(t){if(t){if(t=t.toString(),isNaN(t))throw Error("Parameter is not a number: "+t);"+"==t[0]&&(t=t.substring(1))}else t="0";if(/e/i.test(t)){var r=t.split(/[eE]/),e=r[0],i=r[1];e=n.trim(e),i=parseInt(i)+e.indexOf("."),e=e.replace(".",""),t=e.length<i?e+new Array(i-e.length+1).join("0"):e.length>=i&&i>0?n.trim(e.substring(0,i))+(e.length>i?"."+e.substring(i):""):"0."+new Array(1-i).join("0")+e}return t},t.prototype.getValue=function(){return this.value},t.getPrettyValue=function(r,e,n){if(e||n){if(!e||!n)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else e=3,n=",";r=t.validate(r);var i="-"==r.charAt(0);i&&(r=r.substring(1));var u=r.indexOf(".");u=u>0?u:r.length;for(var a="",o=u;o>0;)o<e?(e=o,o=0):o-=e,a=r.substring(o,o+e)+(o<u-e&&o>=0?n:"")+a;return(i?"-":"")+a+r.substring(u)},t.prototype.getPrettyValue=function(r,e){return t.getPrettyValue(this.value,r,e)},t.round=function(r,e){if(r=t.validate(r),e){if(isNaN(e))throw Error("Precision is not a number: "+e)}else e=0;return i.roundOff(r,e)},t.prototype.round=function(r){if(r){if(isNaN(r))throw Error("Precision is not a number: "+r)}else r=0;return new t(i.roundOff(this.value,r))},t.add=function(r,e){return r=t.validate(r),e=t.validate(e),n.add(r,e)},t.prototype.add=function(r){return new t(n.add(this.value,r.getValue()))},t.subtract=function(r,e){return r=t.validate(r),e=t.validate(e),s.subtract(r,e)},t.prototype.subtract=function(r){return new t(s.subtract(this.value,r.getValue()))},t.multiply=function(r,e){return r=t.validate(r),e=t.validate(e),u.multiply(r,e)},t.prototype.multiply=function(r){return new t(u.multiply(this.value,r.getValue()))},t.divide=function(r,e,n){return r=t.validate(r),e=t.validate(e),a.divide(r,e,n)},t.prototype.divide=function(r,e){return new t(a.divide(this.value,r.getValue(),e))},t.compareTo=function(r,e){return r=t.validate(r),e=t.validate(e),o.compareTo(r,e)},t.prototype.compareTo=function(t){return o.compareTo(this.value,t.getValue())},t.negate=function(r){return r=t.validate(r),s.negate(r)},t.prototype.negate=function(){return new t(s.negate(this.value))},t}();t.exports=l},function(t,r,e){"use strict";function n(t,r){t=t.toString(),r=r.toString();var e=0;"-"==t[0]&&(e++,t=t.substr(1)),"-"==r[0]&&(e++,r=r.substr(1)),t=u(t),r=u(r);var n=0,a=0;-1!=t.indexOf(".")&&(n=t.length-t.indexOf(".")-1),-1!=r.indexOf(".")&&(a=r.length-r.indexOf(".")-1);var o=n+a;if(t=u(t.replace(".","")),r=u(r.replace(".","")),t.length<r.length){var s=t;t=r,r=s}if("0"==r)return"0";for(var l=r.length,f=0,g=[],c=l-1,d="",v=0;v<l;v++)g[v]=t.length-1;for(var v=0;v<2*t.length;v++){for(var p=0,h=r.length-1;h>=c&&h>=0;h--)g[h]>-1&&g[h]<t.length&&(p+=parseInt(t[g[h]--])*parseInt(r[h]));p+=f,f=Math.floor(p/10),d=p%10+d,c--}return d=u(i(d,o)),1==e&&(d="-"+d),d}function i(t,r){return 0==r?t:(t=r>=t.length?new Array(r-t.length+1).join("0")+t:t,t.substr(0,t.length-r)+"."+t.substr(t.length-r,r))}function u(t){for(;"0"==t[0];)t=t.substr(1);if(-1!=t.indexOf("."))for(;"0"==t[t.length-1];)t=t.substr(0,t.length-1);return""==t||"."==t?t="0":"."==t[t.length-1]&&(t=t.substr(0,t.length-1)),"."==t[0]&&(t="0"+t),t}Object.defineProperty(r,"__esModule",{value:!0}),r.multiply=n},function(t,r,e){"use strict";function n(t,r,e){if(void 0===e&&(e=8),0==r)throw new Error("Cannot divide by 0");if(t=t.toString(),r=r.toString(),0==t)return"0";var n=0;"-"==r[0]&&(r=r.substring(1),n++),"-"==t[0]&&(t=t.substring(1),n++);var a=r.indexOf(".")>0?r.length-r.indexOf(".")-1:-1;if(r=i.trim(r.replace(".","")),a>=0){var o=t.indexOf(".")>0?t.length-t.indexOf(".")-1:-1;if(-1==o)t=i.trim(t+new Array(a+1).join("0"));else if(a>o)t=t.replace(".",""),t=i.trim(t+new Array(a-o+1).join("0"));else if(a<o){t=t.replace(".","");var s=t.length-a+a;t=i.trim(t.substring(0,s)+"."+t.substring(s))}else a==o&&(t=i.trim(t.replace(".","")))}var l=0,f=r.length,g="",c=t.indexOf(".")>-1&&t.indexOf(".")<f?t.substring(0,f+1):t.substring(0,f);if(t=t.indexOf(".")>-1&&t.indexOf(".")<f?t.substring(f+1):t.substring(f),c.indexOf(".")>-1){var d=c.length-c.indexOf(".")-1;c=c.replace(".",""),f>c.length&&(d+=f-c.length,c+=new Array(f-c.length+1).join("0")),l=d,g="0."+new Array(d).join("0")}for(e+=2;l<=e;){for(var v=0;parseInt(c)>=parseInt(r);)c=i.add(c,"-"+r),v++;g+=v,t?("."==t[0]&&(g+=".",l++,t=t.substring(1)),c+=t.substring(0,1),t=t.substring(1)):(l||(g+="."),l++,c+="0")}return(1==n?"-":"")+i.trim(u.roundOff(g,e-2))}Object.defineProperty(r,"__esModule",{value:!0});var i=e(0),u=e(1);r.divide=n},function(t,r,e){"use strict";function n(t,r){var e=!1;if("-"==t[0]&&"-"!=r[0])return-1;if("-"!=t[0]&&"-"==r[0])return 1;if("-"==t[0]&&"-"==r[0]&&(t=t.substr(1),r=r.substr(1),e=!0),u=i.pad(t,r),t=u[0],r=u[1],0==t.localeCompare(r))return 0;for(var n=0;n<t.length;n++)if(t[n]!=r[n])return t[n]>r[n]?e?-1:1:e?1:-1;return 0;var u}Object.defineProperty(r,"__esModule",{value:!0});var i=e(0);r.compareTo=n},function(t,r,e){"use strict";function n(t,r){return t=t.toString(),r=r.toString(),r=i(r),u.add(t,r)}function i(t){return t="-"==t[0]?t.substr(1):"-"+t}Object.defineProperty(r,"__esModule",{value:!0});var u=e(0);r.subtract=n,r.negate=i}]);
var bigDecimal=function(t){function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}var e={};return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},r.p="",r(r.s=2)}([function(t,r,e){"use strict";function n(t,r){void 0===r&&(r="0");var e=0,n=-1;"-"==t[0]&&(e++,n=1,t=t.substring(1),t.length),"-"==r[0]&&(e++,n=2,r=r.substring(1),r.length),t=u(t),r=u(r),l=a(u(t),u(r)),t=l[0],r=l[1],1==e&&(1==n?t=i(t):r=i(r));var s=o(t,r);return e?2==e?"-"+u(s):t.length<s.length?u(s.substring(1)):"-"+u(i(s)):u(s);var l}function i(t){for(var r="",e=t.length,n=t.split(".")[1],i=n?n.length:0,u=0;u<e;u++)t[u]>="0"&&t[u]<="9"?r+=9-parseInt(t[u]):r+=t[u];return o(r,i>0?"0."+new Array(i).join("0")+"1":"1")}function u(t){var r=t.split(".");for(r[0]||(r[0]="0");"0"==r[0][0]&&r[0].length>1;)r[0]=r[0].substring(1);return r[0]+(r[1]?"."+r[1]:"")}function a(t,r){var e=t.split("."),n=r.split("."),i=e[0].length,u=n[0].length;return i>u?n[0]=new Array(Math.abs(i-u)+1).join("0")+(n[0]?n[0]:""):e[0]=new Array(Math.abs(i-u)+1).join("0")+(e[0]?e[0]:""),i=e[1]?e[1].length:0,u=n[1]?n[1].length:0,(i||u)&&(i>u?n[1]=(n[1]?n[1]:"")+new Array(Math.abs(i-u)+1).join("0"):e[1]=(e[1]?e[1]:"")+new Array(Math.abs(i-u)+1).join("0")),t=e[0]+(e[1]?"."+e[1]:""),r=n[0]+(n[1]?"."+n[1]:""),[t,r]}function o(t,r){o=a(t,r),t=o[0],r=o[1];for(var e="",n=0,i=t.length-1;i>=0;i--)if("."!==t[i]){var u=parseInt(t[i])+parseInt(r[i])+n;e=u%10+e,n=Math.floor(u/10)}else e="."+e;return n?n.toString()+e:e;var o}Object.defineProperty(r,"__esModule",{value:!0}),r.add=n,r.trim=u,r.pad=a},function(t,r,e){"use strict";function n(t,r){void 0===r&&(r=0),"number"==typeof t&&(t=t.toString());var e=t.split("."),a=e[0],o=e[1];if(r<0){if(r=-r,a.length<=r)return"0";var s=a.substr(0,a.length-r);return t=s+"."+a.substr(a.length-r)+o,(s=n(t))+new Array(r+1).join("0")}if(0==r){a.length;return i(e[1],a)?u(a):a}if(!e[1])return a+"."+new Array(r+1).join("0");if(e[1].length<r)return a+"."+e[1]+new Array(r-e[1].length+1).join("0");o=e[1].substring(0,r);var l=e[1].substring(r);return l&&i(l,o)&&(o=u(o),o.length>r)?u(a,parseInt(o[0]))+"."+o.substring(1):a+"."+o}function i(t,r){return!!t&&(t>"5"+new Array(t.length+1).join("0")||"5"==t&&parseInt(r[r.length-1])%2==1)}function u(t,r){void 0===r&&(r=0),r||(r=1),"number"==typeof t&&t.toString();for(var e=t.length-1,n="",i=e;i>=0;i--){var u=parseInt(t[i])+r;10==u?(r=1,u=0):r=0,n+=u}return r&&(n+=r),n.split("").reverse().join("")}Object.defineProperty(r,"__esModule",{value:!0}),r.roundOff=n},function(t,r,e){"use strict";var n=e(0),i=e(1),u=e(3),a=e(4),o=e(5),s=e(6),l=function(){function t(r){void 0===r&&(r="0"),this.value=t.validate(r)}return t.validate=function(t){if(t){if(t=t.toString(),isNaN(t))throw Error("Parameter is not a number: "+t);"+"==t[0]&&(t=t.substring(1))}else t="0";if(/e/i.test(t)){var r=t.split(/[eE]/),e=r[0],i=r[1];e=n.trim(e),i=parseInt(i)+e.indexOf("."),e=e.replace(".",""),t=e.length<i?e+new Array(i-e.length+1).join("0"):e.length>=i&&i>0?n.trim(e.substring(0,i))+(e.length>i?"."+e.substring(i):""):"0."+new Array(1-i).join("0")+e}return t},t.prototype.getValue=function(){return this.value},t.getPrettyValue=function(r,e,n){if(e||n){if(!e||!n)throw Error("Illegal Arguments. Should pass both digits and separator or pass none")}else e=3,n=",";r=t.validate(r);var i="-"==r.charAt(0);i&&(r=r.substring(1));var u=r.indexOf(".");u=u>0?u:r.length;for(var a="",o=u;o>0;)o<e?(e=o,o=0):o-=e,a=r.substring(o,o+e)+(o<u-e&&o>=0?n:"")+a;return(i?"-":"")+a+r.substring(u)},t.prototype.getPrettyValue=function(r,e){return t.getPrettyValue(this.value,r,e)},t.round=function(r,e){if(r=t.validate(r),e){if(isNaN(e))throw Error("Precision is not a number: "+e)}else e=0;return i.roundOff(r,e)},t.prototype.round=function(r){if(r){if(isNaN(r))throw Error("Precision is not a number: "+r)}else r=0;return new t(i.roundOff(this.value,r))},t.add=function(r,e){return r=t.validate(r),e=t.validate(e),n.add(r,e)},t.prototype.add=function(r){return new t(n.add(this.value,r.getValue()))},t.subtract=function(r,e){return r=t.validate(r),e=t.validate(e),s.subtract(r,e)},t.prototype.subtract=function(r){return new t(s.subtract(this.value,r.getValue()))},t.multiply=function(r,e){return r=t.validate(r),e=t.validate(e),u.multiply(r,e)},t.prototype.multiply=function(r){return new t(u.multiply(this.value,r.getValue()))},t.divide=function(r,e,n){return r=t.validate(r),e=t.validate(e),a.divide(r,e,n)},t.prototype.divide=function(r,e){return new t(a.divide(this.value,r.getValue(),e))},t.compareTo=function(r,e){return r=t.validate(r),e=t.validate(e),o.compareTo(r,e)},t.prototype.compareTo=function(t){return o.compareTo(this.value,t.getValue())},t.negate=function(r){return r=t.validate(r),s.negate(r)},t.prototype.negate=function(){return new t(s.negate(this.value))},t}();t.exports=l},function(t,r,e){"use strict";function n(t,r){t=t.toString(),r=r.toString();var e=0;"-"==t[0]&&(e++,t=t.substr(1)),"-"==r[0]&&(e++,r=r.substr(1)),t=u(t),r=u(r);var n=0,a=0;-1!=t.indexOf(".")&&(n=t.length-t.indexOf(".")-1),-1!=r.indexOf(".")&&(a=r.length-r.indexOf(".")-1);var o=n+a;if(t=u(t.replace(".","")),r=u(r.replace(".","")),t.length<r.length){var s=t;t=r,r=s}if("0"==r)return"0";for(var l=r.length,f=0,g=[],c=l-1,d="",v=0;v<l;v++)g[v]=t.length-1;for(var v=0;v<2*t.length;v++){for(var p=0,h=r.length-1;h>=c&&h>=0;h--)g[h]>-1&&g[h]<t.length&&(p+=parseInt(t[g[h]--])*parseInt(r[h]));p+=f,f=Math.floor(p/10),d=p%10+d,c--}return d=u(i(d,o)),1==e&&(d="-"+d),d}function i(t,r){return 0==r?t:(t=r>=t.length?new Array(r-t.length+1).join("0")+t:t,t.substr(0,t.length-r)+"."+t.substr(t.length-r,r))}function u(t){for(;"0"==t[0];)t=t.substr(1);if(-1!=t.indexOf("."))for(;"0"==t[t.length-1];)t=t.substr(0,t.length-1);return""==t||"."==t?t="0":"."==t[t.length-1]&&(t=t.substr(0,t.length-1)),"."==t[0]&&(t="0"+t),t}Object.defineProperty(r,"__esModule",{value:!0}),r.multiply=n},function(t,r,e){"use strict";function n(t,r,e){if(void 0===e&&(e=8),0==r)throw new Error("Cannot divide by 0");if(t=t.toString(),r=r.toString(),0==t)return"0";var n=0;"-"==r[0]&&(r=r.substring(1),n++),"-"==t[0]&&(t=t.substring(1),n++);var a=r.indexOf(".")>0?r.length-r.indexOf(".")-1:-1;if(r=i.trim(r.replace(".","")),a>=0){var o=t.indexOf(".")>0?t.length-t.indexOf(".")-1:-1;if(-1==o)t=i.trim(t+new Array(a+1).join("0"));else if(a>o)t=t.replace(".",""),t=i.trim(t+new Array(a-o+1).join("0"));else if(a<o){t=t.replace(".","");var s=t.length-a+a;t=i.trim(t.substring(0,s)+"."+t.substring(s))}else a==o&&(t=i.trim(t.replace(".","")))}var l=0,f=r.length,g="",c=t.indexOf(".")>-1&&t.indexOf(".")<f?t.substring(0,f+1):t.substring(0,f);if(t=t.indexOf(".")>-1&&t.indexOf(".")<f?t.substring(f+1):t.substring(f),c.indexOf(".")>-1){var d=c.length-c.indexOf(".")-1;c=c.replace(".",""),f>c.length&&(d+=f-c.length,c+=new Array(f-c.length+1).join("0")),l=d,g="0."+new Array(d).join("0")}for(e+=2;l<=e;){for(var v=0;parseInt(c)>=parseInt(r);)c=i.add(c,"-"+r),v++;g+=v,t?("."==t[0]&&(g+=".",l++,t=t.substring(1)),c+=t.substring(0,1),t=t.substring(1)):(l||(g+="."),l++,c+="0")}return(1==n?"-":"")+i.trim(u.roundOff(g,e-2))}Object.defineProperty(r,"__esModule",{value:!0});var i=e(0),u=e(1);r.divide=n},function(t,r,e){"use strict";function n(t,r){var e=!1;if("-"==t[0]&&"-"!=r[0])return-1;if("-"!=t[0]&&"-"==r[0])return 1;if("-"==t[0]&&"-"==r[0]&&(t=t.substr(1),r=r.substr(1),e=!0),u=i.pad(t,r),t=u[0],r=u[1],0==t.localeCompare(r))return 0;for(var n=0;n<t.length;n++)if(t[n]!=r[n])return t[n]>r[n]?e?-1:1:e?1:-1;return 0;var u}Object.defineProperty(r,"__esModule",{value:!0});var i=e(0);r.compareTo=n},function(t,r,e){"use strict";function n(t,r){return t=t.toString(),r=r.toString(),r=i(r),u.add(t,r)}function i(t){return t="-"==t[0]?t.substr(1):"-"+t}Object.defineProperty(r,"__esModule",{value:!0});var u=e(0);r.subtract=n,r.negate=i}]);
{
"name": "js-big-decimal",
"version": "1.1.6",
"version": "1.1.7",
"description": "Work with large numbers on the client side. Round them off to any required precission.",

@@ -9,5 +9,10 @@ "main": "dist/node/js-big-decimal",

"test": "./node_modules/.bin/jasmine JASMINE_CONFIG_PATH=spec/jasmine.json --helper=spec/helper/*.js",
"test:watch": "chokidar \"lib/**/*.js\" -c \"npm run travis-test\"",
"travis-test": "./node_modules/.bin/jasmine JASMINE_CONFIG_PATH=spec/jasmine.json",
"test-random": "node test/randomtest.js",
"compile": "tsc --watch",
"compile": "tsc",
"compile:watch": "chokidar \"src/**/*.ts\" -c \"npm run compile\"",
"dist": "gulp dist",
"dist:watch": "chokidar \"lib/**/*.js\" -c \"npm run dist\"",
"start": "npm-run-all -s --parallel compile:watch test:watch dist:watch",
"toc": "doctoc --title \"## Contents\" ./README.md"

@@ -14,0 +19,0 @@ },

@@ -8,3 +8,3 @@ # JS Big Decimal

[![npm](https://img.shields.io/npm/dt/js-big-decimal.svg?style=flat-square)](https://www.npmjs.com/package/js-big-decimal)
<!-- [![Github file size](https://img.shields.io/github/size/royNiladri/js-big-decimal/dist/web/js-big-decimal.min.js.svg?style=flat-square)]() -->
[![Github file size](https://img.shields.io/github/size/royNiladri/js-big-decimal/dist/web/js-big-decimal.min.js.svg?style=flat-square)](https://github.com/royNiladri/js-big-decimal/blob/master/dist/web/js-big-decimal.min.js)

@@ -93,3 +93,3 @@ Work with large numbers on the client side with high precision.

### round(number, precision)
Returns the rounded value to the specified precision (number of digits after decimal). The default is set to 0 if no argument is passed.
Returns the rounded value to the specified precision (number of digits after decimal). The default is set to 0 if no argument is passed.
```javascript

@@ -103,2 +103,8 @@ var value = bigDecimal.round("123.678", 2); // value = "123.68"

```
Passing in a negative argument for digits to round off to returns the nearest multiple of power of 10. If the magnitude of the argument is larger than or equal to the number of digits in the integral part of the number to round, `zero` is returned.
```javascript
var val1 = bigDecimal.round("123.78", -2); // val1 = "100"
var val2 = bigDecimal.round("587", -1); // val2 = "590"
var val1 = bigDecimal.round("123.78", -4); // val3 = "0"
```

@@ -105,0 +111,0 @@ ### compareTo(number1, number2)

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc