开发者

Little Endian Encoding

开发者 https://www.devze.com 2023-03-13 19:17 出处:网络
The following b开发者_如何学Pythonyte sequence is encoded as Little Endian Unsigned Int. F0 00 00 00

The following b开发者_如何学Pythonyte sequence is encoded as Little Endian Unsigned Int.

F0 00 00 00 

I just read about endianness. Just wanted to verify if it is 240 decimal.


Translating the byte sequence to bits...

[1111 0000] [0000 0000] [0000 0000] [0000 0000]

Converting the first byte to decimal...

= 0*2^0 + 0*2^1 + 0*2^2 + 0*2^3 + 1*2^4 + 1*2^5 + 1*2^6 + 1*2^7

Doing the math...

= 16 + 32 + 64 + 128 = 240


Yes, 0x000000F0 = 240.

If it were big-endian, it would be 0xF0000000 = 4026531840 (or -268435456 if signed).

0

精彩评论

暂无评论...
验证码 换一张
取 消