select convert(varbinary(8), 1) in MS SQL Server produces output : 0x00000001
On assigning the above query to dataset in Delphi, and accessing field value, we get byte array as [1, 0, 0, 0] . So Bytes[0] contains 1.
When I use IntToHex() on this bytes array it would result me value as “10000000” .
Why is IntToHex considering it in reverse order?
Thanks & Regards,
Pavan.
I think you forgot to include a reference to the code where you’re somehow calling
IntToHexon aTBytesarray. It’s from the answer to your previous question, how to convert byte array to its hex representation in Delphi.In my answer, I forgot to account for how a pointer to an array of bytes would have the bytes in big-endian order while
IntToHex(and everything else on x86) expects them in little-endian order. The solution is to switch them around. I used this function:In the meantime, I fixed my answer to account for that.