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
kotlin.ArithmeticException: Rounding mode with 0 digits precision.
at kotlin.Throwable#<init>(/opt/buildAgent/work/c5a36d4d82b914cf/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt:24)
at kotlin.Exception#<init>(/opt/buildAgent/work/c5a36d4d82b914cf/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:23)
at kotlin.RuntimeException#<init>(/opt/buildAgent/work/c5a36d4d82b914cf/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:34)
at kotlin.ArithmeticException#<init>(/opt/buildAgent/work/c5a36d4d82b914cf/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:119)
at com.ionspin.kotlin.bignum.decimal.DecimalMode#<init>(/Users/ptheisen/Development/kotlin-multiplatform-bignum/bignum/src/commonMain/kotlin/com/ionspin/kotlin/bignum/decimal/DecimalMode.kt:97)
at com.ionspin.kotlin.bignum.decimal.DecimalMode#<init>(/Users/ptheisen/Development/kotlin-multiplatform-bignum/bignum/src/commonMain/kotlin/com/ionspin/kotlin/bignum/decimal/DecimalMode.kt:86)
at com.ionspin.kotlin.bignum.decimal.BigDecimal#divideAndRemainder(/Users/ptheisen/Development/kotlin-multiplatform-bignum/bignum/src/commonMain/kotlin/com/ionspin/kotlin/bignum/decimal/BigDecimal.kt:1334)
Expected behavior
No exception, correct division/remainder result.
val resolvedRoundingMode = this.decimalMode ?: DecimalMode(exponent + 1, RoundingMode.FLOOR)
So when the exponent is -1, the precision resolves to 0, which is reserved for unlimited precision and can't be paired with RoundingMode.FLOOR.
divideAndRemainder is the root cause, but many other methods use it to compute their results and so are also affected (e.g. remainder, isWholeNumber, etc).
The text was updated successfully, but these errors were encountered:
@theisenp fix should be available in an half an hour or so when CI/CD finishes the build. It will be in snapshot version 0.3.4-SNAPSHOT. Once again, thanks for reporting!
Describe the bug
Calling
BigDecimal.divideAndRemainder
throws an exception when the exponent is-1
and no explicitDecimalMode
has been provided.To Reproduce
This statement:
Throws an exception with a stacktrace like this:
Expected behavior
No exception, correct division/remainder result.
Platform
Additional context
The method creates a default decimal mode if none has been set on the dividend:
So when the exponent is
-1
, the precision resolves to0
, which is reserved for unlimited precision and can't be paired withRoundingMode.FLOOR
.divideAndRemainder
is the root cause, but many other methods use it to compute their results and so are also affected (e.g.remainder
,isWholeNumber
, etc).The text was updated successfully, but these errors were encountered: