Normally something like this should do the trick (here 3 decimals and 7 characters for total width):

program Format_Example;
uses
    sysutils;
procedure F( _d: double);
var
   S: String;
begin
     S:= Format('%7.3f',[_d]);
     WriteLn( S);
end;

begin
     F(0.5);
     F(2.53);
     F(12.5);
end.

---------- Output ------------

  0.500
  2.530
 12.500



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

Reply via email to