gciatto / kt-math

Pure Kotlin porting of Java's BigIntegers and BigDecimals (along with java.math.*)
GNU General Public License v2.0
27 stars 4 forks source link

ClassCastException when calling divideAndRemainder for JVM #305

Open hakanai opened 3 weeks ago

hakanai commented 3 weeks ago

Test program:

import org.gciatto.kt.math.BigInteger
fun main() {
    BigInteger.of(5).divideAndRemainder(2)
}

Result:

Exception in thread "main" java.lang.ClassCastException: class org.gciatto.kt.math.JavaBigIntegerAdapter cannot be cast to class java.math.BigInteger (org.gciatto.kt.math.JavaBigIntegerAdapter is in unnamed module of loader 'app'; java.math.BigInteger is in module java.base of loader 'bootstrap')
    at org.gciatto.kt.math.JavaBigIntegerAdapter.divideAndRemainder(JavaBigIntegerAdapter.kt:186)
    at org.gciatto.kt.math.BigInteger$DefaultImpls.divideAndRemainder(BigInteger.kt:157)
    at org.gciatto.kt.math.JavaBigIntegerAdapter.divideAndRemainder(JavaBigIntegerAdapter.kt:5)
    at BigIntegerTestKt.main(BigIntegerTest.kt:4)
    at BigIntegerTestKt.main(BigIntegerTest.kt)