-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiply looses precission #176
Comments
Multiplication didn't loose precision, roundToDigitPositionAfterDecimalPoint was setting a DecimalMode to the number of digits in the result after rounding which then caused multiplication to round to that decimal mode, which in this case was 3. Still I feel this was completely unexpected behavior of roundToDigitPosition methods, so now #177 will change the behavior so they only apply decimal mode after rounding if the users sets it explicitly. |
Oh btw, the fix will be available in 0.3.1-SNAPSHOT as soon as the gitlab build is completed. |
And also, thanks for reporting! |
Will test ASAP, but even when I use
Are my expectations wrong here? The actual result is 238,478295 .. or is this cause by the actual overloaded operator, that does the rounding after each of those operations? |
Or better question is "how to properly do it with this lib"? I have to admit I've expected just using setScale the same way I did with java's BigDecimal |
I am not completely sure, I would have to take step through debugger to see what is going on with your sample, but I don't have time right now. Keep in mind that the when using decimal mode with scale, scale overrides the decimal precision so even if you put 9999 the scale 2 is used. DecimalMode API will be changed at some point to be more user friendly, at the moment there are too many pitfalls. |
…-loss Fix for #176, changed rounding after digit method behavior
Your usage The original cause why this part of the API is not easy to use is because originally the library used only decimal precision, and scale was a later contribution. I'll probably be dropping the decimal precision from the API in the upcoming versions. |
From a quick test with the latest with the latest build that should be available in the snapshots this could work for you
|
Just tested it and it works great. Thanks for the quick fix! |
Can be closed or left until new release is done. 👍 |
Describe the bug
Numbers rounded to specific number of of digits after decimal point multiply incorrectly.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Result should not loose precision same way java BigDecimal.setScale(2, RoundMode.HALF_UP)
Platform
JVM (commonTest run by
testDebugUnitTest
)The text was updated successfully, but these errors were encountered: