How to format & print floating point numbers in Java with leading zeros? -


this question has answer here:

for example: 23.7748884 , 344.456445 numbers working with. looking output format "000.0000". desired result 023.7749 , 344.4564. tried:

string.format("%.4f", 23.7748884) // output: 23.7749, not ok! desired: 023.7749 string.format("%.4f", 344.456445) // output 344.4564, ok! 

you reach such result using like:

string.format("%08.4f", 23.7748884); // results 023.7749 string.format("%08.4f", 344.456445); // results 344.4564 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -