[Bug] NaN error #54
This commit is contained in:
parent
67894925ad
commit
eed466ed05
|
@ -119,21 +119,25 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||
}
|
||||
|
||||
fun handleClear() {
|
||||
val oldValue = displayedNumber
|
||||
var newValue = "0"
|
||||
val len = oldValue!!.length
|
||||
var minLen = 1
|
||||
if (oldValue.contains("-"))
|
||||
minLen++
|
||||
if (displayedNumber.equals(NAN)) {
|
||||
handleReset()
|
||||
} else {
|
||||
val oldValue = displayedNumber
|
||||
var newValue = "0"
|
||||
val len = oldValue!!.length
|
||||
var minLen = 1
|
||||
if (oldValue.contains("-"))
|
||||
minLen++
|
||||
|
||||
if (len > minLen) {
|
||||
newValue = oldValue.substring(0, len - 1)
|
||||
if (len > minLen) {
|
||||
newValue = oldValue.substring(0, len - 1)
|
||||
}
|
||||
|
||||
newValue = newValue.replace("\\.$".toRegex(), "")
|
||||
newValue = formatString(newValue)
|
||||
setValue(newValue)
|
||||
mBaseValue = Formatter.stringToDouble(newValue)
|
||||
}
|
||||
|
||||
newValue = newValue.replace("\\.$".toRegex(), "")
|
||||
newValue = formatString(newValue)
|
||||
setValue(newValue)
|
||||
mBaseValue = Formatter.stringToDouble(newValue)
|
||||
}
|
||||
|
||||
fun handleReset() {
|
||||
|
|
|
@ -13,6 +13,7 @@ val DECIMAL = "decimal"
|
|||
val CLEAR = "clear"
|
||||
val RESET = "reset"
|
||||
|
||||
val NAN = "NaN"
|
||||
val ZERO = "zero"
|
||||
val ONE = "one"
|
||||
val TWO = "two"
|
||||
|
|
Loading…
Reference in New Issue