I am getting incorrect result while performing the division using BigDecimal. number1 = 221500.0 number2 = 12.0 Here is my code snippet:
BigDecimal d1 = new BigDecimal(String.valueOf(number1)).setScale(13, 4);
BigDecimal d2 = new BigDecimal(String.valueOf(number2)).setScale(13, 4);
return (d1.divide(d2, 13, 4 )).doubleValue();
18458.333333333332
if I performed the same calculation using the calculator it gives 18458.333333333333333333333333333
Let me know any issues with handling the scale in BigDecimal. It will be helpful if someone let me know how to arrive the same result with calculator.