Multiplatform BigDecimal implementation?


#1

I’m starting work on a new multiplatform Kotlin project and quickly ran into a snag in trying to use BigDecimal in a platform agnostic way. It’s looking like there will be a lot of work in translating java.math.BigDecimal into a multiplatform expect class, and then providing the JS (and maybe someday down the road, native) implementation.

Was thinking I might just create my own library for it, but does anyone know if this has already been done?


#2

I was thinking about the same thing for Native. So, good idea.


#3

Probably could do it right now: https://www.npmjs.com/package/bigdecimal


#4

This is a biggest blocker for me to use Kotlin Multiplatform. A library would be welcome. Maybe I can contribute.


#5

I’ve set up a first cut at a library at kmulti-bignumber. It has an expect declaration for BigDecimal with some of the essential methods and operators. For the JVM it just directly uses typealias from java.math.BigDecimal. I haven’t done anything on JS or BigInteger yet and probably won’t for awhile, so please send PRs. :slight_smile: