Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Non-terminating decimal expansion; no exact representable decimal result

807580May 18 2010 — edited May 18 2010
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 waht I want to get is 18.88 but although I am setting the scale to 2, it gives me the same error. I dont understand why I have to round this result and just get 18.88 setting the scale to 2. Is a way to do it?
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 15 2010
Added on May 18 2010
2 comments
950 views