ionspin / kotlin-multiplatform-bignum

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

BigDecimal addition producing incorrect results #175

Closed cowmanjoe closed 3 years ago

cowmanjoe commented 3 years ago

Describe the bug When using this library with Kotlin/JS, I've found that incorrect results are produced when adding two BigDecimal numbers together. It appears to put the decimal place in the wrong spot.

To Reproduce Steps to reproduce the behavior:

        val x = BigDecimal.ZERO
        val y = BigDecimal.parseString("0.00007")

        val z = x + y

z equals 7.0 after this runs.

Expected behavior z should equal 0.00007, or perhaps (but probably not) just a rounded 0 value.

Platform JS

If JS (please complete the following information):

ionspin commented 3 years ago

Hi @cowmanjoe could you share which version of the library are you using? This issue (if it is the same issue) was fixed in #174 but the fix is only available in 0.3.1-SNAPSHOT version

cowmanjoe commented 3 years ago

Ah, that's great. I am using 0.2.8. Is there a way to use this snapshot version? It doesn't appear to be present in the maven repository

ionspin commented 3 years ago

Yeah,

repositories {
    maven {
        url = uri("https://oss.sonatype.org/content/repositories/snapshots")
    }
}
implementation("com.ionspin.kotlin:bignum:0.3.1-SNAPSHOT")
cowmanjoe commented 3 years ago

Thank you!