From 4b239d63b617c5d3441c8056d313fefb88540b8c Mon Sep 17 00:00:00 2001 From: Darkempire <50015928+Darkempire78@users.noreply.github.com> Date: Sun, 20 Nov 2022 01:04:20 +0100 Subject: [PATCH] add auto multiply to e --- .../com/darkempire78/opencalculator/Expression.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/darkempire78/opencalculator/Expression.kt b/app/src/main/java/com/darkempire78/opencalculator/Expression.kt index d276516b..5f111d2d 100644 --- a/app/src/main/java/com/darkempire78/opencalculator/Expression.kt +++ b/app/src/main/java/com/darkempire78/opencalculator/Expression.kt @@ -110,7 +110,16 @@ class Expression { cleanCalculation = cleanCalculation.addCharAtIndex('*', i+1) cleanCalculationLength ++ } - if (i-1 >= 0 && (cleanCalculation[i-1] in "123456789)")) { + if (i-1 >= 0 && (cleanCalculation[i-1] in "πe123456789)")) { + cleanCalculation = cleanCalculation.addCharAtIndex('*', i) + cleanCalculationLength ++ + } + } else if (cleanCalculation[i] == 'e') { + if (i+1 < cleanCalculation.length && (cleanCalculation[i+1] in "π123456789(")) { + cleanCalculation = cleanCalculation.addCharAtIndex('*', i+1) + cleanCalculationLength ++ + } + if (i-1 >= 0 && (cleanCalculation[i-1] in "πe123456789)")) { cleanCalculation = cleanCalculation.addCharAtIndex('*', i) cleanCalculationLength ++ }