From 9cc8ac9b54c021bb3da33de99c3faa64bd449209 Mon Sep 17 00:00:00 2001 From: AlbertoPellitteri Date: Mon, 24 May 2021 12:17:12 +0200 Subject: [PATCH] calculatePercentage takes care of the use of the modulo operator --- .../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 70c9b8f..a666e20 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt @@ -223,6 +223,10 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) { val partial = baseValue / (100 / secondValue) baseValue.minus(partial) } + PERCENT -> { + val partial = (baseValue % secondValue) / 100 + partial + } else -> baseValue / (100 * secondValue) } }