mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 00:35:26 +02:00
fix(evaluator): Fix square root rounding error; Closes #18
Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com>
This commit is contained in:
parent
a25e773f83
commit
f313da7042
@ -93,10 +93,10 @@ class Expression(
|
|||||||
}
|
}
|
||||||
|
|
||||||
moveIfMatched(Token.Operator.divide) -> {
|
moveIfMatched(Token.Operator.divide) -> {
|
||||||
val divisor = parseFactor()
|
val divisor = parseFactor().setScale(MAX_PRECISION)
|
||||||
if (divisor.compareTo(BigDecimal.ZERO) == 0) throw ExpressionException.DivideByZero()
|
if (divisor.compareTo(BigDecimal.ZERO) == 0) throw ExpressionException.DivideByZero()
|
||||||
|
|
||||||
expression = expression.divide(divisor, roundingMode)
|
expression = expression.setScale(MAX_PRECISION).divide(divisor, roundingMode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user