ionspin / kotlin-multiplatform-bignum

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

BigDecimal.toPlainString not respecting scale #239

Closed MrStahlfelge closed 1 year ago

MrStahlfelge commented 1 year ago

BigDecimal does not respect a set scale when printing output with toPlainString, while JVM implementation does.

To Reproduce assertEquals("1.000000", 1000000.toBigDecimal().moveDecimalPoint(-6).scale(6).toPlainString())

Succeeds on JVM, fails with this library ("1" returned instead)

Expected behavior Format with set scale.

Problem caused by placeADotInStringExpanded method always truncating trailing zeros.

ionspin commented 1 year ago

Thanks for reporting, you are right it should behave as the JVM counterpart.