|
@@ -582,7 +582,9 @@ export const parseGroups = (tokens: string[]) => { |
|
|
if (token === THOUSAND || token.endsWith(ILLION_SUFFIX)) { |
|
|
if (token === THOUSAND || token.endsWith(ILLION_SUFFIX)) { |
|
|
if (acc.mode === ParseGroupsMode.ONES_MODE) { |
|
|
if (acc.mode === ParseGroupsMode.ONES_MODE) { |
|
|
const ones = ONES.findIndex((o) => o === acc.lastToken); |
|
|
const ones = ONES.findIndex((o) => o === acc.lastToken); |
|
|
lastGroup[0] = `${lastGroup[0].slice(0, 2)}${ones}`; |
|
|
|
|
|
|
|
|
if (ones > -1) { |
|
|
|
|
|
lastGroup[0] = `${lastGroup[0].slice(0, 2)}${ones}`; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
lastGroup[1] = getGroupPlaceFromGroupName(token); |
|
|
lastGroup[1] = getGroupPlaceFromGroupName(token); |
|
@@ -638,6 +640,15 @@ export const parseGroups = (tokens: string[]) => { |
|
|
|
|
|
|
|
|
const tenPlusOnes = TEN_PLUS_ONES.findIndex((t) => t === token); |
|
|
const tenPlusOnes = TEN_PLUS_ONES.findIndex((t) => t === token); |
|
|
if (tenPlusOnes > -1) { |
|
|
if (tenPlusOnes > -1) { |
|
|
|
|
|
if (acc.mode === ParseGroupsMode.THOUSAND_MODE) { |
|
|
|
|
|
return { |
|
|
|
|
|
...acc, |
|
|
|
|
|
lastToken: token, |
|
|
|
|
|
mode: ParseGroupsMode.ONES_MODE, |
|
|
|
|
|
groups: [...acc.groups, [`01${tenPlusOnes}`, lastGroup[1] - 1]], |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
lastGroup[0] = `${lastGroup[0].slice(0, 1)}1${tenPlusOnes}`; |
|
|
lastGroup[0] = `${lastGroup[0].slice(0, 1)}1${tenPlusOnes}`; |
|
|
return { |
|
|
return { |
|
|
...acc, |
|
|
...acc, |
|
@@ -693,7 +704,7 @@ export const combineGroups = (groups: Group[]) => { |
|
|
const exponentSign = isExponentNegative ? NEGATIVE_SYMBOL : POSITIVE_SYMBOL; |
|
|
const exponentSign = isExponentNegative ? NEGATIVE_SYMBOL : POSITIVE_SYMBOL; |
|
|
const exponent = `${exponentSign}${exponentValueAbs}`; |
|
|
const exponent = `${exponentSign}${exponentValueAbs}`; |
|
|
const significandInteger = digits.slice(0, 1); |
|
|
const significandInteger = digits.slice(0, 1); |
|
|
const significandFraction = digits.slice(1); |
|
|
|
|
|
|
|
|
const significandFraction = digits.slice(1).replace(/0+$/, ''); |
|
|
if (significandFraction.length > 0) { |
|
|
if (significandFraction.length > 0) { |
|
|
return `${significandInteger}${DECIMAL_POINT}${significandFraction}${EXPONENT_DELIMITER}${exponent}`; |
|
|
return `${significandInteger}${DECIMAL_POINT}${significandFraction}${EXPONENT_DELIMITER}${exponent}`; |
|
|
} |
|
|
} |
|
|