In Java, I have the following code:
System.out.printf("%05.5f", myFloat);
This works well for any numbers which are less than 10, but for any number 10 or greater, the decimal places are trimmed to 5, but that doesn't compensate for the fact that the number before the decimal point is longer. I'd like to do one of the following:
12.3456
1.23456
(ie, the same number of digits), or:
12.34567
2.34567
(ie, pad with spaces so that the decimal points and last digits line up).
I'd be happy if I could get either to work (both would be even better!).
Any thoughts? Thanks!
29.979748
and then7.449038
(same number of digits after the decimal point, but no leading spaces or 0s). – Recency