kotlin-multiplatform-bignum icon indicating copy to clipboard operation
kotlin-multiplatform-bignum copied to clipboard

Consider changing `ArithmeticException` to `NumberFormatException` in `BigDecimal::parseStringWithMode`.

Open vdshb opened this issue 9 months ago • 1 comments

BigDecimal::parseStringWithMode throws ArithmeticException when input argument is not correctly formatted number. This is a suggestion to enhance API and change it to NumberFormatException as a better choice for this matter (BigInteger::parseString is already using NumberFormatException).

Usages:

https://github.com/ionspin/kotlin-multiplatform-bignum/blob/86b22ce0e2a2b0e163192a1670fe4e0362d5a0ac/bignum/src/commonMain/kotlin/com/ionspin/kotlin/bignum/decimal/BigDecimal.kt#L984

https://github.com/ionspin/kotlin-multiplatform-bignum/blob/86b22ce0e2a2b0e163192a1670fe4e0362d5a0ac/bignum/src/commonMain/kotlin/com/ionspin/kotlin/bignum/decimal/BigDecimal.kt#L1038

vdshb avatar Jul 29 '25 08:07 vdshb

Thanks, you are right, this should be a NumberFormatException, although since this would be a breaking API change, it would need to go to 0.4.0 as the next major release.

ionspin avatar Jul 29 '25 13:07 ionspin