mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-02-09 08:08:51 +01:00
Add division by zero message
This commit is contained in:
parent
879cc8bfc4
commit
5ecff10644
@ -56,13 +56,21 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||||||
val second = secondValue.format()
|
val second = secondValue.format()
|
||||||
val sign = getSign(lastOperation)
|
val sign = getSign(lastOperation)
|
||||||
|
|
||||||
if (sign == "√") {
|
when {
|
||||||
setFormula(sign + first)
|
baseValue == 0.0 && secondValue == 0.0 && sign == "/" -> {
|
||||||
} else if (sign == "!") {
|
setFormula("Error: division by zero")
|
||||||
setFormula(first + sign)
|
}
|
||||||
} else if (!sign.isEmpty()) {
|
|
||||||
var formula = first + sign + second
|
sign == "√" -> setFormula(sign + first)
|
||||||
setFormula(formula)
|
|
||||||
|
sign == "!" -> setFormula(first + sign)
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
if (sign.isNotEmpty()) {
|
||||||
|
val formula = first + sign + second
|
||||||
|
setFormula(formula)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user