View Issue Details

IDProjectCategoryView StatusLast Update
0038202FPCRTLpublic2020-12-13 16:18
ReporterZoran Vučenović Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0038202: Setting Double.Frac loses sign information
DescriptionSetting the Frac helper property of Double clears sign bit.

The bug is actually in TDoubleRec.SetFrac procedure.

The bug does not appear with Single type, only with Double (TSingleRec.SetFrac is implemented correctly).

I am attaching the patch (it is one line only).
Steps To Reproduceprogram Project1;

{$mode objfpc}{$H+}

uses
  SysUtils;

var
  D: Double;
  Q: QWord;

begin
  D := -1;
  WriteLn(D);

  Q := D.Frac;
  D.Frac := Q; // the sign is lost!

  WriteLn(D);

  ReadLn;
end.
 
TagsNo tags attached.
Fixed in Revision47765
FPCOldBugId
FPCTarget-
Attached Files

Activities

Zoran Vučenović

2020-12-10 22:10

reporter  

setfrac.diff (822 bytes)   
��Index: rtl/inc/genmath.inc

===================================================================

--- rtl/inc/genmath.inc	(revision 47749)

+++ rtl/inc/genmath.inc	(working copy)

@@ -2087,7 +2087,7 @@

 

 procedure TDoubleRec.SetFrac(e : QWord);

   begin

-    Data:=(Data and $7ff0000000000000) or (e and $fffffffffffff);

+    Data:=(Data and $fff0000000000000) or (e and $fffffffffffff);

   end;

 

 {

setfrac.diff (822 bytes)   

Florian

2020-12-12 22:39

administrator   ~0127579

Thanks, applied.

Zoran Vučenović

2020-12-13 16:18

reporter   ~0127589

Thank you. Closing.

Issue History

Date Modified Username Field Change
2020-12-10 22:10 Zoran Vučenović New Issue
2020-12-10 22:10 Zoran Vučenović File Added: setfrac.diff
2020-12-12 22:39 Florian Assigned To => Florian
2020-12-12 22:39 Florian Status new => resolved
2020-12-12 22:39 Florian Resolution open => fixed
2020-12-12 22:39 Florian Fixed in Version => 3.3.1
2020-12-12 22:39 Florian Fixed in Revision => 47765
2020-12-12 22:39 Florian FPCTarget => -
2020-12-12 22:39 Florian Note Added: 0127579
2020-12-13 16:18 Zoran Vučenović Status resolved => closed
2020-12-13 16:18 Zoran Vučenović Note Added: 0127589