mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-02-22 06:17:42 +01:00
[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() {
|
fun handleClear() {
|
||||||
val oldValue = displayedNumber
|
if (displayedNumber.equals(NAN)) {
|
||||||
var newValue = "0"
|
handleReset()
|
||||||
val len = oldValue!!.length
|
} else {
|
||||||
var minLen = 1
|
val oldValue = displayedNumber
|
||||||
if (oldValue.contains("-"))
|
var newValue = "0"
|
||||||
minLen++
|
val len = oldValue!!.length
|
||||||
|
var minLen = 1
|
||||||
|
if (oldValue.contains("-"))
|
||||||
|
minLen++
|
||||||
|
|
||||||
if (len > minLen) {
|
if (len > minLen) {
|
||||||
newValue = oldValue.substring(0, len - 1)
|
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() {
|
fun handleReset() {
|
||||||
|
@ -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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user