mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-06-05 21:49:13 +02:00
Confusing behaviour after calculating a square root #28
This commit is contained in:
@ -92,6 +92,11 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||||||
mBaseValue = getDisplayedNumberAsDouble()
|
mBaseValue = getDisplayedNumberAsDouble()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleRoot() {
|
||||||
|
mBaseValue = getDisplayedNumberAsDouble()
|
||||||
|
calculateResult()
|
||||||
|
}
|
||||||
|
|
||||||
private fun calculateResult() {
|
private fun calculateResult() {
|
||||||
if (!mIsFirstOperation) {
|
if (!mIsFirstOperation) {
|
||||||
updateFormula()
|
updateFormula()
|
||||||
@ -107,15 +112,18 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun handleOperation(operation: String) {
|
fun handleOperation(operation: String) {
|
||||||
if (lastKey == DIGIT)
|
if (lastKey == DIGIT && operation != ROOT)
|
||||||
handleResult()
|
handleResult()
|
||||||
|
|
||||||
mResetValue = true
|
mResetValue = true
|
||||||
lastKey = operation
|
lastKey = operation
|
||||||
mLastOperation = operation
|
mLastOperation = operation
|
||||||
|
|
||||||
if (operation == ROOT)
|
if (operation == ROOT) {
|
||||||
calculateResult()
|
handleRoot()
|
||||||
|
mResetValue = false
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleClear() {
|
fun handleClear() {
|
||||||
|
Reference in New Issue
Block a user