Open joffrey-bion opened 10 months ago
Interestingly, when directly using a decimal number, it doesn't give 0:
val mode = DecimalMode(roundingMode = RoundingMode.ROUND_HALF_AWAY_FROM_ZERO, scale = 4)
println("12345678.1234567".toBigDecimal(decimalMode = mode)) // 1.23456781235E+7 (OK)
Hi @joffrey-bion, thanks for reporting, I'll look into this.
I'm getting a potentially related issue when dividing with DecimalMode with unlimited precision and a fixed scale: Dividing 200.5230146281866563757715403019550414480770532190116073 by 1111.99009855 with DecimalMode(roundingMode = RoundingMode.ROUND_HALF_CEILING, scale = 8) yields: 0.00000000
Platform
Workaround: use big but limited decimalPrecision, e.g. DecimalMode(decimalPrecision = 64, roundingMode = RoundingMode.ROUND_HALF_CEILING, scale = 8)
Describe the bug
When using 0 (unlimited) precision with a scale, I get 0 (with weird exponents) each time I have numbers that have more digits than the scale.
To Reproduce
Expected behavior
In this setup, I would expect the scale to be the only thing that's bounded, so that if digits after the decimal point keep going, we round them to the scale. I would expect
12345
to yield1.2345E+4
and12345678
to yield1.2345678E+7
.Platform