Autor Beitrag
Neidhard von Reuental
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 268

XP
BDS 2006 Prof
BeitragVerfasst: Di 07.03.06 09:21 
Hallo,
habe da ein kleines Problem. Ich möchte ein "Array of Byte" in eine Integer64 umwandeln. Wollte es eben mit Pointern machen aber wie ich hier im forum gelesen habe gibts das nicht mehr.
In dem oben verlinkten Post habe ich keine richtige Antwort gefunden, am Ende ging es da nur noch um Rechtschreibung.

Das Array of Byte ist auf die Größe 8 gesetzt.
Hat jemand eine Idee wie ich das ganze realisieren kann?

Cu
Neid


Moderiert von user profile iconChristian S.: Topic aus .NET verschoben am Di 07.03.2006 um 14:14
Moderiert von user profile iconChristian S.: Info-Feld gesetzt
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Di 07.03.06 09:39 
ausblenden Delphi-Quelltext
1:
2:
3:
Result := 0;
for I := 0 to 7 do
  Result := (Result shl 8)+A[I];

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Neidhard von Reuental Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 268

XP
BDS 2006 Prof
BeitragVerfasst: Di 07.03.06 12:33 
Thx für die schnelle Antwort :)
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6386
Erhaltene Danke: 146

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 07.03.06 12:38 
Eigentlich sollte doch auch Convert.ToInt64 funktionieren, oder?
Neidhard von Reuental Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 268

XP
BDS 2006 Prof
BeitragVerfasst: Di 07.03.06 13:09 
Könnte sein, aber gibt es da auch eine rückkonvertierung, also von Int64 in Array of Byte?
Neidhard von Reuental Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 268

XP
BDS 2006 Prof
BeitragVerfasst: Mi 08.03.06 10:21 
So, nach weiterem Suchen habe ich da etwas simples gefunden und daraus einmal 2 Funktionen gebaut.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
type
  A64=Array[0..7of Byte;
.
.
.

function ArrayToInt64(A:A64):int64;
begin
  result:=BitConverter.ToInt64(A,0);
end;

function Int64ToArray(I:Int64):A64;
begin
  Result:=BitConverter.GetBytes(I);
end;


Es ist natürlich, bei der Einfachheit, fraglich ob man das ganze nochmals in Funktionen packt ;)