I'm using DecimalFormat
to round my numbers to exactly with one decimal. However, numbers like 20
don't show up as 20.0
and it just shows 20
.
So my code is like this:
int myWholeNumber = 20;
DecimalFormat df = new DecimalFormat("#.#");
double toDouble = Double.parseDouble(df.format(myWholeNumber));
System.out.println(toDouble);
but the output differs from the wanted one:
Output
20
Wanted
20.0