ionspin / kotlin-multiplatform-bignum

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

BigDecimalWhole.isWholeNumber() wrong when DecimalMode set #238

Closed MrStahlfelge closed 1 year ago

MrStahlfelge commented 2 years ago

Describe the bug BigDecimalWhole.isWholeNumber() wrong when DecimalMode set

To Reproduce

    @Test
    fun testIsWhole() {
        val bigDecimalWhole = "1.1234567826".toBigDecimal(
            decimalMode = DecimalMode(18, RoundingMode.ROUND_HALF_CEILING, 18)
        ).moveDecimalPoint(9)

        assertEquals("1123456782.6", bigDecimalWhole.toPlainString())
        assertEquals(false, bigDecimalWhole.isWholeNumber())
    }

Platform JVM and JS

Additional context Works correct when no DecimalMode is set, but I have to set it to work around #237

ionspin commented 2 years ago

Thanks for reporting both issues!

MrStahlfelge commented 1 year ago

Thanks for looking into it. Do you think we can expect to get it resolved anytime soon? So far I hoped I don't have to move to another solution as this seemed to be the most mature lib.

ionspin commented 1 year ago

Hi @MrStahlfelge, unfortunately I can't promise anything as I have very limited time to work on my open source projects at the moment. Pull requests solving the issue are welcome!

ionspin commented 1 year ago

I'll get on #237 tomorrow hopefully.

ionspin commented 1 year ago

Hey @MrStahlfelge , all issues should be fixed, hopefully the CI/CD will finish soon, but I see that Gitlab runner on windows is getting stuck so it might take some time. Once it finishes the fixes will be available in the current snapshot. You can check the progress of the build here https://gitlab.com/ionspin-github-ci/kotlin-multiplatform-bignum-ci/-/pipelines/602529945

MrStahlfelge commented 1 year ago

Thank you so much! Check the fixes - everything working as expected now.

One note for the future release work: unfortunately I am not able to move to the snapshot because it works only on Kotlin 1.6.21, which is not compatible with Jetbrains Compose (latest version 1.1.1 is for Kotlin 1.6.10). Have to wait until they publish a newer version, but this will most likely depend on 1.7.0.

ionspin commented 1 year ago

Yeah, the compose version requirement for a specific kotlin version is quite unfortunate, I am using the dev releases to stay on relatively current kotlin version.

I'll release the new version of the library with the latest kotlin (1.7.0) in a week or so, you can test that with newer dev-1.2.0 compose build