From 2f46e77ba31043d89d053efa062971d041f2cfa6 Mon Sep 17 00:00:00 2001 From: AlbertoPellitteri Date: Wed, 12 May 2021 09:32:29 +0200 Subject: [PATCH] Add of a simple check in order to fix the division-by-zero bug --- .../simplemobiletools/calculator/helpers/CalculatorImpl.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt index 70c9b8fa..d4e42d07 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt @@ -147,6 +147,10 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) { secondValue = getSecondValue() calculateResult() + if (lastOperation == DIVIDE && secondValue == 0.0){ + lastKey = DIGIT + return + } lastKey = EQUALS }