expansion « decimal « Java Data Type Q&A





1. Non-terminating decimal expansion; no exact representable decimal result    stackoverflow.com

BigDecimal a = new BigDecimal("1.6");
BigDecimal b = new BigDecimal("9.2");
a.divide(b) // results in the following exception.
Is it illegal to do the above operation. Why is that?
java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable ...

2. Non-terminating decimal expansion; no exact representable decimal result    forums.oracle.com

I am using the BigDecimal to represent an amount of money. I am doing some calculations that includes divide so I am getting an error : "Non-terminating decimal expansion; no exact representable decimal result". So I read I have to round the result because I am getting a number like 18.8888888....infinite decimals. But I dont want to round this result because ...