ionspin / kotlin-multiplatform-bignum

A Kotlin multiplatform library for arbitrary precision arithmetics
Apache License 2.0
345 stars 41 forks source link

Attempting to perform an infinite precision BigDecimal exponentiation #200

Closed JoonasC closed 2 years ago

JoonasC commented 2 years ago

The readme mentions that division is the only operation which cannot be performed with infinite precision, but the exponentiation feature uses division internally, which therefore makes exponentiation susceptible to the same problems as division.

Is this a documentation issue or a bug?

ionspin commented 2 years ago

Hi @JoonasC, good catch, this is a documentation issue, it should be mentioned that exponentiation with negative exponents has the same limitation as division. The reason for the limitation is that results of some divisions can be infinitely long, i.e. 1/3 = 0.333333... and the library needs to have way to stop instead of calculating to infinity (or more realistically until it runs out of memory)

JoonasC commented 2 years ago

Could you also implement an exponentation method which accepts a decimal mode?

ionspin commented 2 years ago

Sure, I'll look into that as well!