Java Write Number With Variable Decimal

[Solved] Java Write Number With Variable Decimal | Swift - Code Explorer | yomemimo.com
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

Answers related to java write number with variable decimal

Code Explorer Popular Question For Swift