For integer conversions, specifying a precision implies that the output of the number itself should be zero-padded to this width: printf ’<%.6x>’, 1; # prints "<000001>" printf ’<%#.6x>’, 1; # prints "<0x000001>" printf ’<%-10.6x>’, 1; # prints "<000001 >"