Skip to content

Commit

Permalink
fix decimal then parenthesis causes the application to crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkempire78 committed Dec 1, 2022
1 parent 2f7a737 commit 78d8c09
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/src/main/java/com/darkempire78/opencalculator/Expression.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,17 @@ class Expression {
while (i < cleanCalculationLength) {

if (cleanCalculation[i] == '(') {
if (i != 0 && (cleanCalculation[i-1] in "0123456789)")) {
if (i != 0 && (cleanCalculation[i-1] in "\\${NumberFormatter.decimalSeparatorSymbol}e0123456789)")) {
cleanCalculation = cleanCalculation.addCharAtIndex('*', i)
cleanCalculationLength ++
}
} else if (cleanCalculation[i] == ')') {
if (i+1 < cleanCalculation.length && (cleanCalculation[i+1] in "0123456789(")) {
if (i+1 < cleanCalculation.length && (cleanCalculation[i+1] in "\\${NumberFormatter.decimalSeparatorSymbol}0123456789(")) {
cleanCalculation = cleanCalculation.addCharAtIndex('*', i+1)
cleanCalculationLength ++
}
} else if (cleanCalculation[i] == '!') {
if (i+1 < cleanCalculation.length && (cleanCalculation[i+1] in "0123456789π(")) {
if (i+1 < cleanCalculation.length && (cleanCalculation[i+1] in "\\${NumberFormatter.decimalSeparatorSymbol}0123456789π(")) {
cleanCalculation = cleanCalculation.addCharAtIndex('*', i+1)
cleanCalculationLength ++
}
Expand All @@ -112,20 +112,20 @@ class Expression {
cleanCalculationLength ++
}
} else if (cleanCalculation[i] == 'π') {
if (i+1 < cleanCalculation.length && (cleanCalculation[i+1] in "0123456789(")) {
if (i+1 < cleanCalculation.length && (cleanCalculation[i+1] in "\\${NumberFormatter.decimalSeparatorSymbol}0123456789(")) {
cleanCalculation = cleanCalculation.addCharAtIndex('*', i+1)
cleanCalculationLength ++
}
if (i-1 >= 0 && (cleanCalculation[i-1] in "%πe0123456789)")) {
if (i-1 >= 0 && (cleanCalculation[i-1] in "\\${NumberFormatter.decimalSeparatorSymbol}%πe0123456789)")) {
cleanCalculation = cleanCalculation.addCharAtIndex('*', i)
cleanCalculationLength ++
}
} else if (cleanCalculation[i] == 'e') {
if (i+1 < cleanCalculation.length && (cleanCalculation[i+1] in "π0123456789(")) {
if (i+1 < cleanCalculation.length && (cleanCalculation[i+1] in "\\${NumberFormatter.decimalSeparatorSymbol}π0123456789(")) {
cleanCalculation = cleanCalculation.addCharAtIndex('*', i+1)
cleanCalculationLength ++
}
if (i-1 >= 0 && (cleanCalculation[i-1] in "%πe0123456789)")) {
if (i-1 >= 0 && (cleanCalculation[i-1] in "\\${NumberFormatter.decimalSeparatorSymbol}%πe0123456789)")) {
cleanCalculation = cleanCalculation.addCharAtIndex('*', i)
cleanCalculationLength ++
}
Expand Down

0 comments on commit 78d8c09

Please sign in to comment.