You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The result of BigDecimal.divideAndRemainder are incorrect.:
@Test
funtestRemainder() {
val full =BigDecimal.fromInt(360)
val x =BigDecimal.fromDouble(15.5) + full*5val (q,r) = x.divideAndRemainder(full)
assertEquals("5", q.toStringExpanded()) // got: 5.043
assertEquals("15.5", r.toStringExpanded())
}
quotient must be a whole number first of all. The remainder is invalid too.
Platform
[JVM]
Additional context
I've checked it against java math BigDecimal, it works as expected:
@Test
funtestRemainder2() {
val full = java.math.BigDecimal(360)
val x = java.math.BigDecimal(15.5) + full*java.math.BigDecimal(5)
val divrem = x.divideAndRemainder(full)
assertEquals("5.0", divrem[0].toPlainString())
assertEquals("15.5", divrem[1].toPlainString())
// and the shortcut:
assertEquals("15.5", (x % full).toPlainString())
}
And thanks for this library and Happy New Year!
The text was updated successfully, but these errors were encountered:
The precision needed for rounding was not calculated properly. The fix should be available in snapshot soon. Thanks for reporting and happy new year as well!
It's still counting wrong, if number is less then 1
` @test
fun roundNewText() {
val one = "0.59".toBigDecimal()
val two = "0.1".toBigDecimal()
val result = one.divideAndRemainder(two)
println("result=${result.second.toPlainString()}")
// Result is "0.59"
}
@Test
fun roundNewText() {
val one = "1.59".toBigDecimal()
val two = "0.1".toBigDecimal()
val result = one.divideAndRemainder(two)
println("result=${result.second.toPlainString()}")
// Here result is 0.09
}
Describe the bug
The result of BigDecimal.divideAndRemainder are incorrect.:
Platform
Additional context
I've checked it against java math BigDecimal, it works as expected:
And thanks for this library and Happy New Year!
The text was updated successfully, but these errors were encountered: