mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 00:35:26 +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
|
// Kotlin doesn't have a multi catch
|
||||||
val calculatedInput = try {
|
val calculatedInput = try {
|
||||||
Expressions()
|
Expressions()
|
||||||
.setPrecision(_userPrefs.value.digitsPrecision)
|
// Optimal precision, not too low, not too high. Balanced for performance and UX.
|
||||||
|
.setPrecision(128)
|
||||||
.eval(cleanInput)
|
.eval(cleanInput)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// Kotlin doesn't have a multi catch
|
// Kotlin doesn't have a multi catch
|
||||||
when (e) {
|
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
|
else -> throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user