Browse Source

* fixed type in FloatToStrFIntl introduced in r23311 (mantis #24131)

git-svn-id: trunk@24013 -
Jonas Maebe 12 years ago
parent
commit
7dfe1301c3
3 changed files with 34 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 1 1
      rtl/objpas/sysutils/sysstr.inc
  3. 32 0
      tests/webtbs/tw24131.pp

+ 1 - 0
.gitattributes

@@ -13288,6 +13288,7 @@ tests/webtbs/tw23962.pp svneol=native#text/plain
 tests/webtbs/tw2397.pp svneol=native#text/plain
 tests/webtbs/tw24007.pp svneol=native#text/plain
 tests/webtbs/tw2409.pp svneol=native#text/plain
+tests/webtbs/tw24131.pp svneol=native#text/plain
 tests/webtbs/tw2421.pp svneol=native#text/plain
 tests/webtbs/tw2423.pp svneol=native#text/plain
 tests/webtbs/tw2425.pp svneol=native#text/plain

+ 1 - 1
rtl/objpas/sysutils/sysstr.inc

@@ -1205,7 +1205,7 @@ Begin
           fvDouble:
             Str(Double(Extended(Aligned(Value))):precision+7, Result);
           fvSingle:
-            Str(Single(Extended(Aligned(Value))):precision+66, Result);
+            Str(Single(Extended(Aligned(Value))):precision+6, Result);
           fvCurrency:
 {$ifdef FPC_HAS_STR_CURRENCY}
             Str(Currency(Aligned(Value)):precision+6, Result);

+ 32 - 0
tests/webtbs/tw24131.pp

@@ -0,0 +1,32 @@
+uses
+  SysUtils;
+var
+  s: single;
+begin
+  s := 1.00999;
+  FormatSettings.DecimalSeparator:='.';
+  writeln(FloatToStrF(s, ffGeneral, 8, 0, FormatSettings));
+  writeln(FloatToStrF(s, ffGeneral, 7, 0, FormatSettings));
+  writeln(FloatToStrF(s, ffGeneral, 6, 0, FormatSettings));
+  writeln(FloatToStrF(s, ffGeneral, 5, 0, FormatSettings));
+  writeln(FloatToStrF(s, ffGeneral, 4, 0, FormatSettings));
+  writeln(FloatToStrF(s, ffGeneral, 3, 0, FormatSettings));
+  writeln(FloatToStrF(s, ffGeneral, 2, 0, FormatSettings));
+
+  if FloatToStrF(s, ffGeneral, 8, 0, FormatSettings)<>'1.00999' then
+    halt(1);
+  if FloatToStrF(s, ffGeneral, 7, 0, FormatSettings)<>'1.00999' then
+    halt(2);
+  if FloatToStrF(s, ffGeneral, 6, 0, FormatSettings)<>'1.00999' then
+    halt(3);
+  if FloatToStrF(s, ffGeneral, 5, 0, FormatSettings)<>'1.01' then
+    halt(4);
+  if FloatToStrF(s, ffGeneral, 4, 0, FormatSettings)<>'1.01' then
+    halt(5);
+  if FloatToStrF(s, ffGeneral, 3, 0, FormatSettings)<>'1.01' then
+    halt(6);
+  if FloatToStrF(s, ffGeneral, 2, 0, FormatSettings)<>'1' then
+    halt(7);
+
+
+end.