Closed dankito closed 2 years ago
Hi @dankito , if you find these converters useful, I'd love to add them to the library, so a pull request would be great.
As far as the correctness goes, conversion from java big decimal using string as intermediary would work, but I think it would be too inefficient, so I'd suggest solving that with a more direct approach (i.e. by using Java BigDecimal internal Java BigInteger intValue and scale)
For the conversion to Java Big Decimal, the result wouldn't be completely correct, because significand
can be larger than a long, so just calling longValue()
would lose information. There's already some conversion done in the test classes, so you might take some code from there as inspiration (https://github.com/ionspin/kotlin-multiplatform-bignum/blob/master/bignum/src/jvmTest/kotlin/com/ionspin/kotlin/bignum/decimal/DecimalUtility.kt)
Hi,
I created some extension methods to convert BigDecimal to / from Java BigDecimal (see below).
Two questions here:
Are they correct and do you have any suggestions how to improve them (especially for converting from)?
If i give you a pull request with them, would you like to integrate it into the jvmMain branch of your library?