When does Endianness become a factor?

前端 未结 8 1963
天涯浪人
天涯浪人 2020-12-12 14:52

Endianness from what I understand, is when the bytes that compose a multibyte word differ in their order, at least in the most typical case. So that an 16-bit integer may b

8条回答
  •  我在风中等你
    2020-12-12 15:12

    Both endianesses have an advantage that I know of:

    1. Big-endian is conceptually easier to understand because it's similar to our positional numeral system: most significant to least significant.
    2. Little-endian is convenient when reusing a memory reference for multiple memory sizes. Simply put, if you have a pointer to a little-endian unsigned int* but you know the value stored there is < 256, you can cast your pointer to unsigned char*.

提交回复
热议问题