Einzelnen Beitrag anzeigen

schwa226

Registriert seit: 4. Apr 2008
400 Beiträge
 
#8

AW: Byte Array to UInt64

  Alt 6. Apr 2011, 06:27
Jetzt nocheinmal dazu:

warum geht das nicht:
Delphi-Quellcode:
function TUInt64Rec2.GetUInt64 : UInt64;
begin
  Result :=
    (_Byte[0] Shl 56) or
    (_Byte[1] Shl 48) or
    (_Byte[2] Shl 40) or
    (_Byte[3] Shl 32) or
    (_Byte[4] Shl 24) or
    (_Byte[5] Shl 16) or
    (_Byte[6] Shl 8) or
    _Byte[7];
end;
Zitat:
[DCC Fehler] E1012 Konstantenausdruck verletzt untere Grenzen
Wie kann man sonst aus 8 Bytes ein 64Bit UInt machen?

Edit:
Es scheint an shl zu liegen. So geht es:
Delphi-Quellcode:
function TUInt64Rec2.GetUInt64 : UInt64;
var
  i1, i2 : UInt64;
begin

  i1 :=
    (_Byte[0] Shl 24) or
    (_Byte[1] Shl 16) or
    (_Byte[2] Shl 8) or
    _Byte[3];

  i2 :=
    (_Byte[4] Shl 24) or
    (_Byte[5] Shl 16) or
    (_Byte[6] Shl 8) or
    _Byte[7];

  Result := (i1 shl 32) or i2;
end;
Delphi 2010, Update 4 & 5

Geändert von schwa226 ( 6. Apr 2011 um 06:46 Uhr)
  Mit Zitat antworten Zitat