mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-02-02 17:07:09 +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 sign = getSign(lastOperation)
|
||||
|
||||
if (sign == "√") {
|
||||
setFormula(sign + first)
|
||||
} else if (sign == "!") {
|
||||
setFormula(first + sign)
|
||||
} else if (!sign.isEmpty()) {
|
||||
var formula = first + sign + second
|
||||
setFormula(formula)
|
||||
when {
|
||||
baseValue == 0.0 && secondValue == 0.0 && sign == "/" -> {
|
||||
setFormula("Error: division by zero")
|
||||
}
|
||||
|
||||
sign == "√" -> setFormula(sign + first)
|
||||
|
||||
sign == "!" -> setFormula(first + sign)
|
||||
|
||||
else -> {
|
||||
if (sign.isNotEmpty()) {
|
||||
val formula = first + sign + second
|
||||
setFormula(formula)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user