From e49ebd094dd19c106cb0b1afa62bb3735b1be864 Mon Sep 17 00:00:00 2001 From: Joel Santirso Date: Mon, 30 Jun 2014 19:35:20 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Remove=20the=20=C2=B1=20character?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's not supported by Github's online editor, and the "+-" string was being used throughout the code already --- decimal.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/decimal.js b/decimal.js index 492f363..ddf0db9 100644 --- a/decimal.js +++ b/decimal.js @@ -1461,15 +1461,15 @@ * ECMAScript compliant. * * x is any value, including NaN. - * n is any number, including ±Infinity unless stated. + * n is any number, including +-Infinity unless stated. * * pow( x, NaN ) = NaN - * pow( x, ±0 ) = 1 + * pow( x, +-0 ) = 1 * pow( NaN, nonzero ) = NaN * pow( abs(n) > 1, +Infinity ) = +Infinity * pow( abs(n) > 1, -Infinity ) = +0 - * pow( abs(n) == 1, ±Infinity ) = NaN + * pow( abs(n) == 1, +-Infinity ) = NaN * pow( abs(n) < 1, +Infinity ) = +0 * pow( abs(n) < 1, -Infinity ) = +Infinity * pow( +Infinity, n > 0 ) = +Infinity From 4bfa4549447309f7b25e44eca6820f7bf8e74651 Mon Sep 17 00:00:00 2001 From: Joel Santirso Date: Mon, 30 Jun 2014 19:37:37 +0200 Subject: [PATCH 2/3] Add optional decimal separator to "toFormat" Resolves MikeMcl/decimal.js#6 --- decimal.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/decimal.js b/decimal.js index ddf0db9..d1ee6a5 100644 --- a/decimal.js +++ b/decimal.js @@ -1268,17 +1268,18 @@ * [sep1] {string} The grouping separator of the integer part of the number. * [sep2] {string} The grouping separator of the fraction part of the number. * [dp] {number} Decimal places. Integer, -MAX_DIGITS to MAX_DIGITS inclusive. + * [dsep] {string} Decimal separator, if left undefined it defaults to '.'. * * Non-breaking thin-space: \u202f * * If dp is invalid the error message will incorrectly give the method as toFixed. * */ - P['toFormat'] = function ( sep1, dp, sep2 ) { + P['toFormat'] = function ( sep1, dp, sep2, dsep ) { var arr = this.toFixed(dp).split('.'); return arr[0].replace( /\B(?=(\d{3})+$)/g, sep1 == null ? ',' : sep1 + '' ) + - ( arr[1] ? '.' + ( sep2 ? arr[1].replace( /\d{5}\B/g, '$&' + sep2 ) : arr[1] ) : '' ); + ( arr[1] ? (dsep == null ? '.' : dsep) + ( sep2 ? arr[1].replace( /\d{5}\B/g, '$&' + sep2 ) : arr[1] ) : '' ); }; From 08efe8935c6be172601641f5ddb412376ed60215 Mon Sep 17 00:00:00 2001 From: Joel Santirso Date: Wed, 2 Jul 2014 12:49:25 +0200 Subject: [PATCH 3/3] Adapt format --- decimal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decimal.js b/decimal.js index d1ee6a5..a61d529 100644 --- a/decimal.js +++ b/decimal.js @@ -1279,7 +1279,7 @@ var arr = this.toFixed(dp).split('.'); return arr[0].replace( /\B(?=(\d{3})+$)/g, sep1 == null ? ',' : sep1 + '' ) + - ( arr[1] ? (dsep == null ? '.' : dsep) + ( sep2 ? arr[1].replace( /\d{5}\B/g, '$&' + sep2 ) : arr[1] ) : '' ); + ( arr[1] ? ( dsep == null ? '.' : dsep ) + ( sep2 ? arr[1].replace( /\d{5}\B/g, '$&' + sep2 ) : arr[1] ) : '' ); };