Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.157 Beiträge
 
Delphi 12 Athens
 
#12

Re: Exponent aus Extended extrahieren?

  Alt 2. Mai 2009, 18:49
also hier (D2009)ging das so,

wobei die direkte Integerversion doch eigentlich das Bessere sein sollte?

da es sich von den Speicheradressen nix nimmt, sollte es auch so gehn
und bei mir geht es auch.
Delphi-Quellcode:
uses Math;

type PFIXCOMMA64 = ^FIXCOMMA64;
  FIXCOMMA64 = packed record
    strict private
      FBCD9: int64;
    private
    public
      class operator implicit(const float: Extended): FIXCOMMA64;
      class operator implicit(const rect: FIXCOMMA64): Extended;
      class operator Multiply(const Left, Right: FIXCOMMA64): FIXCOMMA64;
    end;

class operator FIXCOMMA64.implicit(const float: Extended): FIXCOMMA64;
  begin
    Result.FBCD9 := Round(float * 1000000000);
  end;

class operator FIXCOMMA64.implicit(const rect: FIXCOMMA64): Extended;
  begin
    Result := rect.FBCD9 / 1000000000;
  end;

class operator FIXCOMMA64.Multiply(const Left, Right: FIXCOMMA64): FIXCOMMA64;
  const
    idiv: LongInt = 1000000000;
  asm
    fild qword ptr [&left]
    fild qword ptr [&right]
    fmulp st(1), st(0)
    fidiv dword ptr [&idiv]
    fistp qword ptr [&result]
    wait
  end;

procedure TForm2.FormCreate(Sender: TObject);
  var
    f1, f2, f3: FIXCOMMA64;
  begin
    f1 := 1234.56789;
    f2 := 9876.54321;
    f3 := f1 * f2;
    if SameValue(f3, 12193263.111, 0.001) then
      Beep;
  end;
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat