Sfoglia il codice sorgente

* patch by Bart B: FormatFloat correctly outputs NaN now, resolves #32868
+ test

florian 2 anni fa
parent
commit
989895c82f
2 ha cambiato i file con 19 aggiunte e 0 eliminazioni
  1. 5 0
      rtl/objpas/sysutils/fmtflt.inc
  2. 14 0
      tests/webtbs/tw32868.pp

+ 5 - 0
rtl/objpas/sysutils/fmtflt.inc

@@ -317,6 +317,11 @@ var
 begin
 begin
   Result:=0;
   Result:=0;
   Initvars;
   Initvars;
+  if E.IsNan then
+    begin
+    AddToResult('NaN');
+    Exit;
+    end;
   // What section to use ?
   // What section to use ?
   if (E>0) then
   if (E>0) then
     S:=1
     S:=1

+ 14 - 0
tests/webtbs/tw32868.pp

@@ -0,0 +1,14 @@
+program project1;
+
+{$mode objfpc}{$H+}
+
+uses
+  Math,SysUtils;
+
+begin
+  if FormatFloat('0.#',Nan)<>'NaN' then
+    begin
+      WriteLn(FormatFloat('0.#',Nan));
+      halt(1);
+    end;
+end.