Your problem is not a loss of accuracy, but the output format of your number and its number of decimal places. You can use DecimalFormat to solve your problem.
DecimalFormat formatter = new DecimalFormat("#0.00"); String d = new String("12.00"); Double dble = new Double(d.valueOf(d)); System.out.println(formatter.format(dble));
I will also add that you can use DecimalFormatSymbols to choose which decimal separator to use. For example, point:
DecimalFormatSymbols separator = new DecimalFormatSymbols(); separator.setDecimalSeparator('.');
Then by declaring your DecimalFormat :
DecimalFormat formatter = new DecimalFormat("#0.00", separator);
source share