diff --git a/lib/type/bignumber/BigNumber.js b/lib/type/bignumber/BigNumber.js index af0c88981..895dfb5fd 100644 --- a/lib/type/bignumber/BigNumber.js +++ b/lib/type/bignumber/BigNumber.js @@ -1,9 +1,7 @@ var Decimal = require('decimal.js'); function factory (type, config, load, typed, math) { - //var BigNumber = Decimal.clone(config); // TODO: use this shorter notation after https://github.com/MikeMcl/decimal.js/issues/26 is fixed - var BigNumber = Decimal.clone(); - BigNumber.config(config); + var BigNumber = Decimal.clone({precision: config.precision}); /** * Attach type information diff --git a/package.json b/package.json index c6a1bdc82..6cbc45968 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "unit" ], "dependencies": { - "decimal.js": "5.0.3", + "decimal.js": "5.0.4", "fraction.js": "3.2.5", "complex.js": "1.9.6", "tiny-emitter": "1.0.2", diff --git a/test/utils/bignumber/constants.test.js b/test/utils/bignumber/constants.test.js index b52d0b209..6997e6487 100644 --- a/test/utils/bignumber/constants.test.js +++ b/test/utils/bignumber/constants.test.js @@ -1,10 +1,8 @@ // test bignumber utils var assert = require('assert'); var BigNumber = require('decimal.js'); -var Big32 = BigNumber.clone(); -Big32.config({precision: 32}); -var Big64 = BigNumber.clone(); -Big64.config({precision: 64}); +var Big32 = BigNumber.clone({precision: 32}); +var Big64 = BigNumber.clone({precision: 64}); var constants = require('../../../lib/utils/bignumber/constants'); describe('bignumber', function() { diff --git a/test/utils/bignumber/formatter.test.js b/test/utils/bignumber/formatter.test.js index 07800676a..b35ead661 100644 --- a/test/utils/bignumber/formatter.test.js +++ b/test/utils/bignumber/formatter.test.js @@ -9,8 +9,7 @@ describe('format', function () { var B = null; before (function () { - B = BigNumber.clone(); - B.config({precision: 20}); // ensure the precision is 20 digits + B = BigNumber.clone({precision: 20}); // ensure the precision is 20 digits }); it ('should format special values Infinity, NaN', function () { @@ -142,8 +141,7 @@ describe('format', function () { }); it('should format bignumbers with custom precision, lower, and upper bound', function() { - var Big = BigNumber.clone(); - Big.config({precision: 100}); + var Big = BigNumber.clone({precision: 100}); var options = { notation: 'auto', @@ -219,8 +217,7 @@ describe('format', function () { }); it('should format a bignumber using toFixed', function() { - var Big = BigNumber.clone(); - Big.config({precision: 100}); + var Big = BigNumber.clone({precision: 100}); assert.equal(formatter.toFixed(new Big(2.34)), '2'); assert.equal(formatter.toFixed(new Big(2.34), 1), '2.3'); @@ -231,8 +228,7 @@ describe('format', function () { }); it('should format a bignumber using toExponential', function() { - var Big = BigNumber.clone(); - Big.config({precision: 100}); + var Big = BigNumber.clone({precision: 100}); assert.equal(formatter.toExponential(new Big(2.34)), '2.34e+0'); assert.equal(formatter.toExponential(new Big(2.34e+3)), '2.34e+3');