BigDecimal val = BigDecimal.valueOf(0.20);
System.out.println(a);
I want to store in val a value 0.20 and not 0.2. What I
EDIT: this answer is wrong as pointed out in the comments :| thx Andreas_D
The problem is that there is no mathematical difference between 0.2 and 0.20 so your only chance is to display a certain number of digits after the decimal point. Once you store 0.2 or 0.20 in a BigDecimal they are indistinguishable from each other