How to convert Big Endian and how to flip the highest bit?

前端 未结 2 539
慢半拍i
慢半拍i 2021-01-19 16:46

I am using a TStream to read binary data (thanks to this post: How to use a TFileStream to read 2D matrices into dynamic array?).

My next problem is that the data is

2条回答
  •  滥情空心
    2021-01-19 17:27

    Well, I don't know too much about byte swapping, but flipping a single bit is easy. XOR your value with a mask whose binary representation is all 0s, except for a 1 for the bit you want to flip. If you want the most significant bit, in hex that works out to $80 for a single byte, $8000 for a word and, you guessed it, $80000000 for a double word.

提交回复
热议问题