Support Article
PRPC function calculation incorrect
SA-7309
Summary
When Developer is trying to perfrom the multiplication of a large decimal number the result showing up is not correct.
For example, if the price is 20000000000000.123456789, and the quantity is 1.00, the total should be 20000000000000.123456. (Since qunatity is 1, the result should be the same as price.)
However, clipboard, the result is slightly different.
.Price 20000000000000.123456789
.Quantity 1.00
.Total 20000000000000.125000
Creating a simple function (ScaleFormat) in PRPC that will fix the digits to 6 after decimal point, Use this function to format the result of two values multiplication. The function is just rounding floor, and the correct answer should be 20000000000000.123456.
Resolution
Suggested to use String constructor for BigDecimal is more accurate than the decimal constructor when multiplying.
Published January 31, 2016 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.