I am trying to write a report and have the decimal points in the various numbers line up properly. But using say %4.2f or % 4.2f or %04.2f all have the same problem when the value in question is zero. Is there a format spec that will fix this?
perl -e'$fmt="\n%3d : %04.2f : %3d";printf $fmt,3,12.34,-1;printf $fmt,2,00.00,1;print "\n";'Result
3 : 12.34 : -1 2 : 0.00 : 1
In reply to Line up cols using printf %m.nf by pgmer6809
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |