[fpc-pascal] TFloatHelper.BuildUp() question

Bart bartjunk64 at gmail.com
Fri Dec 15 20:39:42 CET 2017


On Fri, Dec 15, 2017 at 1:36 PM, Bart <bartjunk64 at gmail.com> wrote:

> Procedure BuildUp(const ASignFlag: Boolean; const AMantissa: QWord;
> const AExponent: Integer);


Basically the current implementation does this:

    Self :=  0.0;
    TExtended80Rec(Self)._Exp:=(TExtended80Rec(Self)._Exp and $7FFF)
or (ord(AsignFlag) shl 15); //which is what TExtended80Rec(Self).Sign
:= ASignFlag does
    TExtended80Rec(Self).Frac := AMantissa and $000FFFFFFFFFFFFF;
    TExtended80Rec(Self)._Exp:=(TExtended80Rec(Self)._Exp and $8000)
or ((AExponent+$3FF) and $7FFF);   //where does the +$3FF come from?

Possibly this should be:

   Self :=  0.0;
   TExtended80Rec(Self)._Exp:=(TExtended80Rec(Self)._Exp and $7FFF) or
(ord(AsignFlag) shl 15);
   TExtended80Rec(Result).Frac := AMantissa or $8000000000000000;
   TExtended80Rec(Result)._Exp := (Textended80Rec(Result)._Exp and
$8000) or (AExp and $7FFFF);

I'm not very good with bit manipulation, so I may be way off here.

Bart



More information about the fpc-pascal mailing list