%03f should work as one would expect. Reference: /n/atom/patch/0ffmt Date: Mon Mar 3 03:34:11 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/libc/fmt/fltfmt.c Mon Mar 3 03:33:25 2014 +++ /sys/src/libc/fmt/fltfmt.c Mon Mar 3 03:33:26 2014 @@ -303,7 +303,7 @@ * which is 341 currently. */ xdtoa(fmt, s, f); - fmt->flags &= FmtWidth|FmtLeft; + fmt->flags &= FmtZero|FmtWidth|FmtLeft; _fmtcpy(fmt, s, strlen(s), strlen(s)); return 0; } --- /sys/src/libc/fmt/dofmt.c Mon Mar 3 03:33:28 2014 +++ /sys/src/libc/fmt/dofmt.c Mon Mar 3 03:33:29 2014 @@ -87,13 +87,14 @@ int _fmtpad(Fmt *f, int n) { - char *t, *s; + char *t, *s, c; int i; t = f->to; s = f->stop; + c = f->flags&FmtZero? '0': ' '; for(i = 0; i < n; i++) - FMTCHAR(f, t, s, ' '); + FMTCHAR(f, t, s, c); f->nfmt += t - (char *)f->to; f->to = t; return 0; @@ -102,13 +103,14 @@ int _rfmtpad(Fmt *f, int n) { - Rune *t, *s; + Rune *t, *s, r; int i; t = f->to; s = f->stop; + r = f->flags&FmtZero? '0': ' '; for(i = 0; i < n; i++) - FMTRCHAR(f, t, s, ' '); + FMTRCHAR(f, t, s, r); f->nfmt += t - (Rune *)f->to; f->to = t; return 0;