Browse Source

* fixed real48 to double conversion for 0.0 (patch by "jeng", mantis #16863)

git-svn-id: trunk@15543 -
Jonas Maebe 15 years ago
parent
commit
26cc281390
3 changed files with 16 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 7 0
      rtl/inc/genmath.inc
  3. 8 0
      tests/webtbs/tw16863.pp

+ 1 - 0
.gitattributes

@@ -10527,6 +10527,7 @@ tests/webtbs/tw16803.pp svneol=native#text/plain
 tests/webtbs/tw1681.pp svneol=native#text/plain
 tests/webtbs/tw1681.pp svneol=native#text/plain
 tests/webtbs/tw16820.pp svneol=native#text/plain
 tests/webtbs/tw16820.pp svneol=native#text/plain
 tests/webtbs/tw16861.pp svneol=native#text/plain
 tests/webtbs/tw16861.pp svneol=native#text/plain
+tests/webtbs/tw16863.pp svneol=native#text/plain
 tests/webtbs/tw16874.pp svneol=native#text/plain
 tests/webtbs/tw16874.pp svneol=native#text/plain
 tests/webtbs/tw1696.pp svneol=native#text/plain
 tests/webtbs/tw1696.pp svneol=native#text/plain
 tests/webtbs/tw1699.pp svneol=native#text/plain
 tests/webtbs/tw1699.pp svneol=native#text/plain

+ 7 - 0
rtl/inc/genmath.inc

@@ -1403,6 +1403,13 @@ function fpc_int64_to_double(i : int64): double; compilerproc;
          exponent : word;
          exponent : word;
 
 
       begin
       begin
+         { check for zero }
+         if r[0]=0 then
+           begin
+             real2double:=0.0;
+             exit;
+           end;
+
          { copy mantissa }
          { copy mantissa }
          res[0]:=0;
          res[0]:=0;
          res[1]:=r[1] shl 5;
          res[1]:=r[1] shl 5;

+ 8 - 0
tests/webtbs/tw16863.pp

@@ -0,0 +1,8 @@
+var
+    d : double;
+    r : real48 = ($0, $0, $0, $0, $0, $0); 
+BEGIN
+    d := r;
+    if d<>0.0 then
+      halt(1);
+END.