How do people deal with BigDecimal for currency in...
# multiplatform
c
How do people deal with BigDecimal for currency in multiplatform? Is there a library to workaround the lack of support? https://discuss.kotlinlang.org/t/multiplatform-bigdecimal-implementation/5631
l
There is a Kotlin bigint library that you can use.
I created my own bigint and rational multiplatform library instead. I wanted to do that since I wanted to call into native libraries (specifically gmp on Linux).
j
@Chrys If you need one for iOS, https://github.com/kendy/Kotlin-Native-BigDecimal is a drop-in replacement for java.math.BigDecimal. I've ported that from Android & use it in production. Happy to answer any questions.
🙌 1
d
We also invented an `expect`/`actual` based KMP library over
BigDecimal
&
NSDecimalNumber
, along with a battery of Unit Tests to ensure the same resulting 'take' on what string formatting and resulting precisions across sequences of operations look like. You wouldn't think there could be a different opinion on how much classes behave, but the devil is always in the detail... I wish I could share the library but it's company IP.
l
d
@Jan Holešovský I'm trying to implement the crossoid library but getting an error :
Copy code
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.crossoid:kotlin-native-bigdecimal:1.0.
Any thoughts? EDIT: Ah I see, it requires a special maven() repo, any plans to move this to mavenCentral() ?
j
@David Aleksanyan I was hoping GitHub repos are good enough 😉 But I think there were more requests for moving it to mavenCentral(), so I'll have to have a look at that... Can you use the GitHub repo in the meantime?
❤️ 1
d
I just did, works great! Thanks for your work!
324 Views