On Sat, 22 Feb 2014, Mark Morgan Lloyd wrote:

Is it possible to get Format() to pad with leading zeros rather than spaces, particularly in the case of hex numbers? My understanding is that printf() interprets e.g. %02s as being padded with zeros.

For string arguments, this is not possible.
You can use %.2d for this, or %.2x for hex numbers:

araminta: >./tf
000F
araminta: >cat tf.pp
uses sysutils;

begin
  writeln(format('%.4x',[15]));
end.


In a similar vein, am I correct in understanding that FPC's Format() doesn't allow the case to be controlled in hex output? C's printf() distinguishes between %x and %X for case control.

You are correct in your understanding.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to