Fix formatted, signed floats with a thousands separator after the minus sign, e.g. "-,123,456.789"

This commit is contained in:
Ansgar Becker
2009-11-23 21:57:34 +00:00
parent cdb936b77d
commit 6b5c692d3b

View File

@@ -1841,13 +1841,16 @@ end;
}
function FormatNumber( str: String ): String; Overload;
var
i, p: Integer;
i, p, Left: Integer;
begin
Result := str;
Result := StringReplace(Result, '.', DecimalSeparator, [rfReplaceAll]);
p := Pos(DecimalSeparator, Result);
if p = 0 then p := Length(Result)+1;
if p > 0 then for i:=p-1 downto 2 do begin
Left := 2;
if (Length(Result) >= 1) and (Result[1] = '-') then
Left := 3;
if p > 0 then for i:=p-1 downto Left do begin
if (p-i) mod 3 = 0 then
Insert(ThousandSeparator, Result, i);
end;