Browse Source

* patch by Zoran Vučenović: fixes TDoubleRec.SetFrac, resolves #38202
+ test

git-svn-id: trunk@47765 -

florian 4 years ago
parent
commit
53a4e6c513
3 changed files with 23 additions and 1 deletions
  1. 1 0
      .gitattributes
  2. 1 1
      rtl/inc/genmath.inc
  3. 21 0
      tests/webtbs/tw38202.pp

+ 1 - 0
.gitattributes

@@ -18605,6 +18605,7 @@ tests/webtbs/tw3814.pp svneol=native#text/plain
 tests/webtbs/tw38145a.pp svneol=native#text/pascal
 tests/webtbs/tw38145a.pp svneol=native#text/pascal
 tests/webtbs/tw38145b.pp svneol=native#text/pascal
 tests/webtbs/tw38145b.pp svneol=native#text/pascal
 tests/webtbs/tw38151.pp svneol=native#text/pascal
 tests/webtbs/tw38151.pp svneol=native#text/pascal
+tests/webtbs/tw38202.pp svneol=native#text/pascal
 tests/webtbs/tw3827.pp svneol=native#text/plain
 tests/webtbs/tw3827.pp svneol=native#text/plain
 tests/webtbs/tw3829.pp svneol=native#text/plain
 tests/webtbs/tw3829.pp svneol=native#text/plain
 tests/webtbs/tw3833.pp svneol=native#text/plain
 tests/webtbs/tw3833.pp svneol=native#text/plain

+ 1 - 1
rtl/inc/genmath.inc

@@ -2087,7 +2087,7 @@ function TDoubleRec.GetFrac : QWord;
 
 
 procedure TDoubleRec.SetFrac(e : QWord);
 procedure TDoubleRec.SetFrac(e : QWord);
   begin
   begin
-    Data:=(Data and $7ff0000000000000) or (e and $fffffffffffff);
+    Data:=(Data and $fff0000000000000) or (e and $fffffffffffff);
   end;
   end;
 
 
 {
 {

+ 21 - 0
tests/webtbs/tw38202.pp

@@ -0,0 +1,21 @@
+program Project1;
+
+{$mode objfpc}{$H+}
+
+uses
+  SysUtils;
+
+var
+  D: Double;
+  Q: QWord;
+
+begin
+  D := -1;
+
+  Q := D.Frac;
+  D.Frac := Q; // the sign is lost!
+
+  if D<>-1 then
+    halt(1);
+  WriteLn('ok');
+end.