From 6b5c692d3b3a2fe4499dd9e169d021f65f4dd552 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 23 Nov 2009 21:57:34 +0000 Subject: [PATCH] Fix formatted, signed floats with a thousands separator after the minus sign, e.g. "-,123,456.789" --- source/helpers.pas | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/helpers.pas b/source/helpers.pas index b5a88bb1..a64f7675 100644 --- a/source/helpers.pas +++ b/source/helpers.pas @@ -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;