From 9804fd527b382df62e255f6ec432e5e33e0c7fcb Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 2 Dec 2012 16:57:41 +0000 Subject: [PATCH] * 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 - --- .gitattributes | 1 + rtl/objpas/sysutils/sysstr.inc | 2 +- tests/webtbs/tw13076.pp | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/webtbs/tw13076.pp diff --git a/.gitattributes b/.gitattributes index 49fa6ad11e..59a0844036 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/rtl/objpas/sysutils/sysstr.inc b/rtl/objpas/sysutils/sysstr.inc index bc930c75e3..16336ac961 100644 --- a/rtl/objpas/sysutils/sysstr.inc +++ b/rtl/objpas/sysutils/sysstr.inc @@ -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); diff --git a/tests/webtbs/tw13076.pp b/tests/webtbs/tw13076.pp new file mode 100644 index 0000000000..6ea5c8bbcd --- /dev/null +++ b/tests/webtbs/tw13076.pp @@ -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.