mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-20 01:05:26 +02:00
Fixed expression evaluation ("=" click)
This commit is contained in:
parent
2ee69c5b9c
commit
ce614aa172
@ -99,7 +99,11 @@ internal class CalculatorViewModel @Inject constructor(
|
||||
fun evaluate() {
|
||||
// Input and output can change while saving in history. This way we cache it here (i think)
|
||||
val output = _output.value
|
||||
if (!Expression(textFieldController.inputTextWithoutFormatting()).checkSyntax()) return
|
||||
|
||||
// Output can be empty when input and output are identical (for exampel when user entered
|
||||
// just a number, not expression
|
||||
if (output.isEmpty()) return
|
||||
if (!Expression(textFieldController.inputTextWithoutFormatting().clean).checkSyntax()) return
|
||||
|
||||
// Save to history
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
@ -139,6 +143,7 @@ internal class CalculatorViewModel @Inject constructor(
|
||||
.setMinimumRequiredScale(_userPrefs.value.digitsPrecision)
|
||||
.trimZeros()
|
||||
|
||||
// Output will be empty if it's same as input
|
||||
try {
|
||||
val inputBigDecimal = BigDecimal(currentInput)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user