Geht zumindest etwas schlanker.
Delphi-Quellcode:
function FormatFloat2(
const AValue: Extended;
const ADigits, ADecimals: Byte;
const AFormatSettings: TFormatSettings):
string;
begin
var Fmt :=
string.Create('
0', ADigits);
var L := Fmt.Length - 3;
while L > 1
do begin
Insert('
,', Fmt, L);
Dec(L, 3);
end;
Fmt := Fmt + '
.' +
string.Create('
0', ADecimals);
Result := FormatFloat(Fmt, AValue, AFormatSettings);
end;
Edit: Das muss natürlich L > 1 heißen.