Closed pacive closed 1 year ago
Jumping through a few hoops made it work:
(Tibber_Currentprice - Tibber_Meanprice).toBigDecimal.divide(Tibber_Pricestddev.state.toBigDecimal, Java::JavaMath::RoundingMode::HALF_UP)
Could adding the RoundingMode to https://github.com/boc-tothefuture/openhab-jruby/blob/main/lib/openhab/dsl/types/decimal_type.rb#L159-L164 solve the issue?
Edit: This also worked, curiously enough without the rounding mode:
(Tibber_Currentprice - Tibber_Meanprice) / (Tibber_Pricestddev.to_d)
So I have a workaround now at least.
:tada: This issue has been resolved in version 4.45.1 :tada:
The release is available on:
4.45.1
Your semantic-release bot :package::rocket:
Just encountered a freak error when trying to do some math:
Non-terminating decimal expansion; no exact representable decimal result. (Java::JavaLang::ArithmeticException)
I guess it would be hard to reproduce, since it probably depends on the state of the items at the time of the calculation, but this is the code, and full log output (might be reproducible using items with these exact states, but not sure):
Seems to be some issue with BigDecimal, but doing som other calculations using BigDecimal doesn't err:
gives
Also, doing the exact same thing in Rules DSL works, even when explicitly converting to BigDecimal: