mirror of
https://github.com/MikeMcl/decimal.js.git
synced 2024-10-27 20:34:12 +00:00
Support underscores as separators
This commit is contained in:
parent
69e91fecd2
commit
c29c80c6e3
@ -122,7 +122,7 @@ The methods that return a Decimal can be chained.
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
x.dividedBy(y).plus(z).times(9).floor()
|
x.dividedBy(y).plus(z).times(9).floor()
|
||||||
x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').ceil()
|
x.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4_444_562_598.111772').ceil()
|
||||||
```
|
```
|
||||||
|
|
||||||
Many method names have a shorter alias.
|
Many method names have a shorter alias.
|
||||||
@ -235,7 +235,7 @@ then
|
|||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
will create *decimal.min.js*, and a source map will also be added to the *doc* directory.
|
will create *decimal.min.js* and a source map.
|
||||||
|
|
||||||
## Licence
|
## Licence
|
||||||
|
|
||||||
|
@ -3597,7 +3597,10 @@
|
|||||||
function parseOther(x, str) {
|
function parseOther(x, str) {
|
||||||
var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
|
var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
|
||||||
|
|
||||||
if (str === 'Infinity' || str === 'NaN') {
|
if (str.indexOf('_') > -1) {
|
||||||
|
str = str.replace(/(\d)_(?=\d)/g, '$1');
|
||||||
|
if (isDecimal.test(str)) return parseDecimal(x, str);
|
||||||
|
} else if (str === 'Infinity' || str === 'NaN') {
|
||||||
if (!+str) x.s = NaN;
|
if (!+str) x.s = NaN;
|
||||||
x.e = NaN;
|
x.e = NaN;
|
||||||
x.d = null;
|
x.d = null;
|
||||||
|
@ -3593,7 +3593,10 @@ function parseDecimal(x, str) {
|
|||||||
function parseOther(x, str) {
|
function parseOther(x, str) {
|
||||||
var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
|
var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
|
||||||
|
|
||||||
if (str === 'Infinity' || str === 'NaN') {
|
if (str.indexOf('_') > -1) {
|
||||||
|
str = str.replace(/(\d)_(?=\d)/g, '$1');
|
||||||
|
if (isDecimal.test(str)) return parseDecimal(x, str);
|
||||||
|
} else if (str === 'Infinity' || str === 'NaN') {
|
||||||
if (!+str) x.s = NaN;
|
if (!+str) x.s = NaN;
|
||||||
x.e = NaN;
|
x.e = NaN;
|
||||||
x.d = null;
|
x.d = null;
|
||||||
|
@ -301,6 +301,7 @@ new Decimal('0xff.8') // '255.5'
|
|||||||
|
|
||||||
new Decimal(0.046875) // '0.046875'
|
new Decimal(0.046875) // '0.046875'
|
||||||
new Decimal('0.046875000000') // '0.046875'
|
new Decimal('0.046875000000') // '0.046875'
|
||||||
|
new Decimal('0.046_875_000_000') // '0.046875'
|
||||||
|
|
||||||
new Decimal(4.6875e-2) // '0.046875'
|
new Decimal(4.6875e-2) // '0.046875'
|
||||||
new Decimal('468.75e-4') // '0.046875'
|
new Decimal('468.75e-4') // '0.046875'
|
||||||
|
Loading…
Reference in New Issue
Block a user