Please can anyone help me.
how to i but a qlonglong to a ByteArray with this Order
Example:
In Java:
Long n = 60243;
ByteBuffer byteBufferData = ByteBuffer.allocate(16);
byteBufferData.putLong(turnoverCounter);
Long n = 60243;
ByteBuffer byteBufferData = ByteBuffer.allocate(16);
byteBufferData.putLong(turnoverCounter);
To copy to clipboard, switch view to plain text mode
I got this Array "0 0 0 0 0 0 -21 83 0 0 0 0 0 0 0 0"
I only need the first 8 Bytes "0 0 0 0 0 0 -21 83"
In Cpp (Qt5):
qlonglong n = 60243;
for(int i = 0; i != sizeof(n); ++i)
{
ba.append((char)((n & (0xFF << (i*8))) >> (i*8)));
}
qlonglong n = 60243;
QByteArray ba;
for(int i = 0; i != sizeof(n); ++i)
{
ba.append((char)((n & (0xFF << (i*8))) >> (i*8)));
}
To copy to clipboard, switch view to plain text mode
I got the right length but in other order;
I got "83 -21 0 0 0 0 0 0"
How can i reverse this? can i put this in the reverse order in the loop? Or is this any problem?
Thx Chris
Bookmarks