please me translating java code pascal.
comment: prepare data here, 8 bytes used turnover counter (more enough every possible turnover...), specification requires 5 bytes @ minimum bytes 0-7 used turnover counter, represented 8-byte two-complement, big endian representation (equal java long), bytes 8-15 set 0 negative values possible (very rare)
long turnovercounter = 50501; bytebuffer bytebufferdata = bytebuffer.allocate(16); bytebufferdata.putlong(turnovercounter); byte[] data = bytebufferdata.array(); // data result = [0, 0, 0, 0, 0, 0, -59, 69, 0, 0, 0, 0, 0, 0, 0, 0]
java bytebuffer data.putlong interested in pascal
thank you.
pascal equivalent of java long
int64
, , need change endianness; example
type tbufferdata = array[0..15] of byte; tlongbytes = array[0..7] of byte; procedure putlong(var buffer: tbufferdata; l: int64); begin buffer[0]:= tlongbytes(l)[7]; buffer[1]:= tlongbytes(l)[6]; buffer[2]:= tlongbytes(l)[5]; buffer[3]:= tlongbytes(l)[4]; buffer[4]:= tlongbytes(l)[3]; buffer[5]:= tlongbytes(l)[2]; buffer[6]:= tlongbytes(l)[1]; buffer[7]:= tlongbytes(l)[0]; end;
note byte
signed type in java, it's direct equivalent in pascal shortint
(byte
unsigned type in pascal).
Comments
Post a Comment