Merge pull request #55 from ensozos/Issue#54

[Bug] NaN error #54
This commit is contained in:
Tibor Kaputa
2018-01-06 14:28:33 +01:00
committed by GitHub
2 changed files with 18 additions and 13 deletions

View File

@@ -127,6 +127,9 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
} }
fun handleClear() { fun handleClear() {
if (displayedNumber.equals(NAN)) {
handleReset()
} else {
val oldValue = displayedNumber val oldValue = displayedNumber
var newValue = "0" var newValue = "0"
val len = oldValue!!.length val len = oldValue!!.length
@@ -143,6 +146,7 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
setValue(newValue) setValue(newValue)
mBaseValue = Formatter.stringToDouble(newValue) mBaseValue = Formatter.stringToDouble(newValue)
} }
}
fun handleReset() { fun handleReset() {
resetValues() resetValues()

View File

@@ -13,6 +13,7 @@ val DECIMAL = "decimal"
val CLEAR = "clear" val CLEAR = "clear"
val RESET = "reset" val RESET = "reset"
val NAN = "NaN"
val ZERO = "zero" val ZERO = "zero"
val ONE = "one" val ONE = "one"
val TWO = "two" val TWO = "two"