Reputation: 81
Format('%7.8f', [varFloat]) formatting only decimals.
For example 13,98 becomes 13,98000000. What I have to use is : 00000013,98000000
I know it is a dull question, but I am running short of time and I can not find why is not working as I would like.
Upvotes: 1
Views: 343
Reputation: 612954
If you are prepared to reach into the system C runtime you can use sprintf
. For example:
{$APPTYPE CONSOLE}
function sprintf(buf: Pointer; format: PAnsiChar): Integer; cdecl;
varargs; external 'msvcrt.dll';
var
buf: array [0..255] of AnsiChar;
val: Double;
begin
val := 13.98;
sprintf(@buf, '%015.8f', val);
Writeln(buf);
Readln;
end.
This outputs:
000013.98000000
You might contemplate choosing a variant that protects against buffer overruns.
But FormatFloat
would be easier.
Upvotes: 1