function ExtendedToString(zahl: extended; tausender: boolean): string;
var
pe, pk, i, k, m, z: integer;
ex: boolean;
hlp: string;
begin
result := floattostr(zahl);
pe := pos('E', result);
if pe > 0 then begin
ex := copy(result, pe + 1, 1) = '-';
i := strtoint(copy(result, pe + 1 + ord(ex), maxint));
result := copy(result, 1, pe - 1);
pk := pos(Decimalseparator, result);
if pk = 0 then z := 0
else begin
delete(result, pk, 1);
z := 2;
end;
if ex then begin
result := stringofchar('0', i - pk + z) + result;
k := pk - i;
if k < 2 then k := 2;
insert(Decimalseparator, result, k);
end else
result := result + stringofchar('0', i + ord(pk > 0) * (pk - pe + 1));
end else begin
hlp := FloatToStrF(zahl, ffFixed, 18, 18);
if length(hlp) > length(result) then result := hlp;
while (pos(Decimalseparator, result) > 0)
and ((ansilastchar(result) = '0')
or (ansilastchar(result) = Decimalseparator))
do delete(result, length(result), 1);
end;
if not tausender then exit;
pk := pos(',', result);
if pk = 0 then i := length(result) - 2
else i := pk - 3;
m := ord(copy(result, 1, 1) = '-') + 1;
while i > m do begin
insert(Thousandseparator, result, i);
dec(i, 3);
end;
end;
// Beispielaufrufe
procedure TForm1.Button4Click(Sender: TObject);
var zahl: extended;
begin
zahl := 1.23456789E-12;
Label1.caption := Floattostr(zahl); // 1,23456789E-12
Label2.caption := FloatToStrF(zahl, ffFixed, 18, 18); // 0,000000000001234568
Label3.caption := ExtendedToString(zahl, false); // 0,00000000000123456789
end;
procedure TForm1.Button5Click(Sender: TObject);
var zahl: extended;
begin
zahl := 1.23456789E+4;
Label1.caption := ExtendedToString(zahl, false); // 12345,6789
Label2.caption := ExtendedToString(zahl, true); // 12.345,6789
end;