* don't add a thousands separator in FormatFloat if there are no digits

before it because the value is too small, regardless of what the format
   pattern sepcifies (patch by Bart Broersma, mantis #13076)

git-svn-id: trunk@23095 -
This commit is contained in:
Jonas Maebe 2012-12-02 16:57:41 +00:00
parent c4d8396158
commit 9804fd527b
3 changed files with 30 additions and 1 deletions

1
.gitattributes vendored
View File

@ -12427,6 +12427,7 @@ tests/webtbs/tw12993.pp svneol=native#text/plain
tests/webtbs/tw13015.pp svneol=native#text/plain
tests/webtbs/tw13019.pp svneol=native#text/plain
tests/webtbs/tw13075.pp svneol=native#text/plain
tests/webtbs/tw13076.pp svneol=native#text/plain
tests/webtbs/tw1310.pp svneol=native#text/plain
tests/webtbs/tw13110.pp svneol=native#text/plain
tests/webtbs/tw13133.pp svneol=native#text/plain

View File

@ -2277,7 +2277,7 @@ Var
end;
If thousand And (Digits[N]<>'-') Then
Begin
If (DigitExponent Mod 3 = 0) And (DigitExponent>0) Then
If (DigitExponent Mod 3 = 0) And (DigitExponent>0) and (N > 1) Then
Begin
Buf[0] := FormatSettings.ThousandSeparator;
Inc(Buf);

28
tests/webtbs/tw13076.pp Normal file
View File

@ -0,0 +1,28 @@
{$ifdef fpc}
{$mode objfpc}
{$endif}
program tw12385;
uses
SysUtils;
var
s: string;
cr: Extended;
Procedure TestIt(CR : Extended; Fmt,Expected : String);
begin
S:=FormatFloat(Fmt,cr);
If S<>Expected then
begin
Writeln('"',S,'"<>"',Expected,'" (latter is correct)');
Halt(1);
end;
end;
begin
DecimalSeparator:='.';
ThousandSeparator:=',';
TestIt(-10,'###,###,##0.00','-10.00');
end.