1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2026-09-23 04:14:32 +00:00

Support underscores as separators

This commit is contained in:
Michael Mclaughlin
2021-06-22 13:22:53 +01:00
parent 69e91fecd2
commit c29c80c6e3
4 changed files with 12 additions and 5 deletions

View File

@@ -3596,8 +3596,11 @@
*/
function parseOther(x, str) {
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;
x.e = NaN;
x.d = null;