Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Brauche Hilfe beim Umrechnen von INt64 Wert (https://www.delphipraxis.net/138785-brauche-hilfe-beim-umrechnen-von-int64-wert.html)

SimStar001 17. Aug 2009 16:30


Brauche Hilfe beim Umrechnen von INt64 Wert
 
Hallo, welchem Variablentyp entspricht S64? Int64?

turboPASCAL 17. Aug 2009 16:37

Re: Variablentypen?
 
Was und woher kommt denn dein S64, C ?
Wie Schaut dort die Definition aus ?

SimStar001 17. Aug 2009 16:44

Re: Variablentypen?
 
aus dem Flight Simulator von Microsoft bzw der FSUIPC...
Var Type = S64 Size = 8 comment = #*360/(65536*65536*65536*65536))

himitsu 17. Aug 2009 16:57

Re: Variablentypen?
 
size = 8 klingt schonmal nach 64 Bit

Aufgrund von /(65536*65536*65536*65536) (wer ist bloß auf diese komische Idee gekommen?)
würde ich eher zu UInt64 tendieren

SimStar001 17. Aug 2009 17:53

Re: Variablentypen?
 
s ich habe nochmal ne erklärung gefunden...

Zitat:

Longitude of aircraft in FS format.

To convert to Degrees:

If your compiler supports long long (64-bit) integers then use such a variable to simply copy this 64-bit value into a double floating point variable and multiply by 360.0/(65536.0 * 65536.0 * 65536.0 * 65536.0).

Otherwise you will have to handle the high 32-bits and the low 32-bits separately, combining them into one double floating point value (say dHi). To do, copy the high part (the 32-bit int at 056C) to one double and the low part (the 32-bit unsigned int at 0568) to another (say dLo). Remember that the low part is only part of a bigger number, so doesn’t have a sign of its own. Divide dLo by (65536.0 * 65536.0) to give it its proper magnitude compared to the high part, then either add it to or subtract it from dHi according to whether dHi is positive or negative. This preserves the integrity of the original positive or negative number. Finally multiply the result by 360.0/(65536.0 * 65536.0) to get degrees.

Either way, a negative result is West, positive East. If you did it all unsigned then values over 180.0 represent West longitudes of (360.0 – the value).

[Can be written to move aircraft: in FS2002 only in slew or pause states]

Delphi-Quellcode:
procedure TForm1.Button2Click(Sender: TObject);
var dwresult : dword;
    Longitude : int64;
    wert : int64;
    Latitude : int64;
    lat : extended;
    temp : string;
begin
  FSUIPC_Open(SIM_ANY, dwResult) ;
  if FSUIPC_Read($0568, 3, @wert, dwResult) then
  if FSUIPC_Process(dwResult) then
    begin
    wert := wert * 360;
    showmessage(floattostr( (wert/ 65536 / 65536 / 65536 /65536)));
    end;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:03 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz