Question : java write number with variable decimal
Answered by : jirka-sasek
double value = 12345.67890123456;
for (int decimals = 0; decimals <= 10; decimals++) { String output = String.format("%." + decimals + "f", value); System.out.println(output);
}
Source : https://stackoverflow.com/questions/60467620/change-the-decimal-places-by-number-from-variable-java | Last Update : Sat, 05 Mar 22