mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-18 16:25:27 +02:00
Fixed calculated result precision
This commit is contained in:
parent
cc1c94e86e
commit
7fc6cea761
@ -107,12 +107,13 @@ class MainViewModel @Inject constructor(
|
||||
// Kotlin doesn't have a multi catch
|
||||
val calculatedInput = try {
|
||||
Expressions()
|
||||
.setPrecision(_userPrefs.value.digitsPrecision)
|
||||
// Optimal precision, not too low, not too high. Balanced for performance and UX.
|
||||
.setPrecision(128)
|
||||
.eval(cleanInput)
|
||||
} catch (e: Exception) {
|
||||
// Kotlin doesn't have a multi catch
|
||||
when (e) {
|
||||
is ExpressionException, is ArrayIndexOutOfBoundsException, is NumberFormatException -> return mainFlow.value.resultValue
|
||||
is ExpressionException, is ArrayIndexOutOfBoundsException, is NumberFormatException, is ArithmeticException -> return mainFlow.value.resultValue
|
||||
else -> throw e
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user