[fpc-pascal] Formatting Question
James Richters
james.richters at productionautomation.net
Sun Apr 4 02:41:56 CEST 2021
That looks almost perfect.. can I suppress the trailing zeros with the format command without losing the alignment?
James Richters
<http://www.productionautomation.net> www.productionautomation.net
<mailto:james at productionautomation.net> james at productionautomation.net
(813)-763-1110
From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> On Behalf Of Jean SUZINEAU via fpc-pascal
Sent: Saturday, April 3, 2021 4:41 PM
To: fpc-pascal at lists.freepascal.org
Cc: Jean SUZINEAU <jean.suzineau at wanadoo.fr>
Subject: Re: [fpc-pascal] Formatting Question
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20210403/af31fd2a/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 27981 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20210403/af31fd2a/attachment-0001.png>
More information about the fpc-pascal
mailing list