This content has been marked as final. Show 4 replies
When you use the constructor of BigDecimal that takes a string, the precision of that string becomes the precision of the BigDecimal. In your example, it's precise to exactly no decimal places, hence so is your BigDecimal. Try this
Bingo. Your BigDecimal is, and always will be, precise to two decimal places
BigDecimal bd = new BigDecimal("25000000.12");
Yes, that works, but I have to convert my double number to a String first, and that conversion gives as result 2.5E7, that's why I get 2.5E+7 as the result of the conversion to BigDecimal, but I can�t use the constructor exactly as you said...
Thanks for your reply
Then do a different conversion that formats the number correctly. Are you using a DecimalFormat object to do the conversion?
Edit: No, I see you aren't. Use one.
Yes, that worked very good.
Thank you very much!