ソースを参照

+ added (not yet fixed)

git-svn-id: trunk@2381 -
Jonas Maebe 19 年 前
コミット
440637d72d
2 ファイル変更52 行追加0 行削除
  1. 1 0
      .gitattributes
  2. 51 0
      tests/test/tstrreal3.pp

+ 1 - 0
.gitattributes

@@ -5680,6 +5680,7 @@ tests/test/tstring7.pp svneol=native#text/plain
 tests/test/tstring8.pp svneol=native#text/plain
 tests/test/tstrreal1.pp svneol=native#text/plain
 tests/test/tstrreal2.pp svneol=native#text/plain
+tests/test/tstrreal3.pp -text
 tests/test/tsubdecl.pp svneol=native#text/plain
 tests/test/tunit1.pp svneol=native#text/plain
 tests/test/tunit2.pp svneol=native#text/plain

+ 51 - 0
tests/test/tstrreal3.pp

@@ -0,0 +1,51 @@
+{ test by Graeme Geldenhuys }
+
+{$mode delphi}
+uses sysutils;
+
+
+procedure test;
+var
+ Result: string;
+ e: extended;
+ r: double;
+begin
+ e := 234.502;
+ Result := FloatToStrF(e, ffGeneral, 15, 0);
+// Memo1.Lines.Add(Result);      { prints 234.502  }
+ writeln(result);
+ if (result <> '234.502') then
+   halt(1);
+
+ r := 234.502;
+ Result := FloatToStrF(r, ffGeneral, 15, 0);
+// Memo1.Lines.Add(Result);  { prints 234.50200000000001 }
+ writeln(result);
+ if (result <> '234.502') then
+   halt(1);
+
+ r := 234.501;
+ Result := FloatToStrF(r, ffGeneral, 15, 0);
+// Memo1.Lines.Add(Result);  { prints 234.501  Why does this work? }
+ writeln(result);
+ if (result <> '234.501') then
+   halt(1);
+
+ r := 7.502;
+ Result := FloatToStrF(r, ffGeneral, 15, 0);
+// Memo1.Lines.Add(Result);  { prints 7.502 }
+ writeln(result);
+ if (result <> '7.502') then
+   halt(1);
+
+ r := 8.502;
+ Result := FloatToStrF(r, ffGeneral, 15, 0);
+// Memo1.Lines.Add(Result);  { prints 8.502000000000001 }
+ writeln(result);
+ if (result <> '8.502') then
+   halt(1);
+end;
+
+begin
+  test;
+end.