Einzelnen Beitrag anzeigen

WojTec

Registriert seit: 17. Mai 2007
482 Beiträge
 
Delphi XE6 Professional
 
#18

Re: AW: C++ pointer to byte array --> Delphi

  Alt 2. Dez 2013, 23:06
You ignored me

I believe I explained why the upcast is necessary.
Oh, no, I didn't ignored you

You explained, but I still don't understand.

I checked it in this sample:

Delphi-Quellcode:
const
  C: Char = 'X';
var
  B: Byte absolute C;
begin
  ShowMessage(IntToStr(B shl 8)); // 22528
  ShowMessage(IntToStr((256*Byte(C)) shl 8)); // 5767168
  ShowMessage(IntToStr(Cardinal(Ord(C) shl 8))); // 22528
end;
Could you check in C++ what it returns? In Delphi I have 2901454111 for 'Delphi' string and 4357 seed.

Code:
#define mix(a,b,c) \
{ \
  a -= b; a -= c; a ^= ( c >> 13 ); \
  b -= c; b -= a; b ^= ( a << 8 ); \
  c -= a; c -= b; c ^= ( b >> 13 ); \
  a -= b; a -= c; a ^= ( c >> 12 ); \
  b -= c; b -= a; b ^= ( a << 16 ); \
  c -= a; c -= b; c ^= ( b >> 5 ); \
  a -= b; a -= c; a ^= ( c >> 3 ); \
  b -= c; b -= a; b ^= ( a << 10 ); \
  c -= a; c -= b; c ^= ( b >> 15 ); \
}
  Mit Zitat antworten Zitat