Skip to content

Commit

Permalink
feature-request #92 (#93)
Browse files Browse the repository at this point in the history
* Bugfix #84 fixed buggy round

* 1.3.11

* 1.3.12

* bugfix #63: fix addition of -0

* build files

* 1.3.13

* added devcontainer

* changed gulpfile for macos

* added feature 'abs' #83

* 1.3.14

* added abs to readme

* 1.3.15

* semantic dependency updates

* Add feature for #32 setValue

* 1.4.0

* Merge branch 'master' of https://github.com/royNiladri/js-big-decimal into development

* upadted packagelock

* 1.4.1

---------

Co-authored-by: Niladri Roy <[email protected]>
  • Loading branch information
royNiladri and Niladri Roy authored Feb 11, 2023
1 parent 07e4fc3 commit 863ff87
Show file tree
Hide file tree
Showing 10 changed files with 5,389 additions and 4,194 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- [Operations](#operations)
- [bigDecimal(number)](#bigdecimalnumber)
- [getValue()](#getvalue)
- [setValue()](#setvalue)
- [getPrettyValue(number, digits, separator)](#getprettyvaluenumber-digits-separator)
- [round(number, precision, roundingMode)](#roundnumber-precision-roundingmode)
- [abs(number)](#absnumber)
Expand Down Expand Up @@ -97,6 +98,14 @@ Returns the string value of the decimal.
console.log(n2.getValue()); // "12345.6789"
```

### setValue()
Allows setting the BigDecimal to a new value.
```js
var n = new bigDecimal('123');
n.setvalue('567');
console.log(n.getValue()); // 567
```

### getPrettyValue(number, digits, separator)
By default this returns the number in standard number format, comma after every three digits. Both arguments, `digits` - the number of digits (of the integral part) to group by, and `separator` - the character to mark the separation. Example of this can be to format a 16 digit number as _credit card_.
```javascript
Expand Down
5 changes: 3 additions & 2 deletions dist/node/big-decimal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ declare class bigDecimal {
private static validate;
constructor(number?: (number | string | bigint));
getValue(): string;
setValue(num: (number | string | bigint)): void;
static getPrettyValue(number: any, digits: any, separator: any): string;
getPrettyValue(digits: any, separator: any): string;
static round(number: any, precision?: number, mode?: Modes): string;
Expand All @@ -25,8 +26,8 @@ declare class bigDecimal {
divide(number: bigDecimal, precision: any): bigDecimal;
static modulus(number1: any, number2: any): string;
modulus(number: bigDecimal): bigDecimal;
static compareTo(number1: any, number2: any): 1 | -1 | 0;
compareTo(number: bigDecimal): 1 | -1 | 0;
static compareTo(number1: any, number2: any): 0 | 1 | -1;
compareTo(number: bigDecimal): 0 | 1 | -1;
static negate(number: any): string;
negate(): bigDecimal;
}
Expand Down
3 changes: 3 additions & 0 deletions dist/node/js-big-decimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ var bigDecimal = /** @class */ (function () {
bigDecimal.prototype.getValue = function () {
return this.value;
};
bigDecimal.prototype.setValue = function (num) {
this.value = bigDecimal.validate(num);
};
bigDecimal.getPrettyValue = function (number, digits, separator) {
if (!(digits || separator)) {
digits = 3;
Expand Down
2 changes: 1 addition & 1 deletion dist/node/js-big-decimal.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/web/js-big-decimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ var bigDecimal = /** @class */ (function () {
bigDecimal.prototype.getValue = function () {
return this.value;
};
bigDecimal.prototype.setValue = function (num) {
this.value = bigDecimal.validate(num);
};
bigDecimal.getPrettyValue = function (number, digits, separator) {
if (!(digits || separator)) {
digits = 3;
Expand Down
2 changes: 1 addition & 1 deletion dist/web/js-big-decimal.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 863ff87

Please sign in to comment.