Skip to content

Commit

Permalink
[Doc]: add little endian more definition
Browse files Browse the repository at this point in the history
  • Loading branch information
HarleysZhang committed Feb 27, 2023
1 parent 6e76492 commit 5a75a95
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
### 1.3,寻址和字节顺序
**对于跨越多个字节的程序对象,我们必须建立两个规则: 这个对象的地址是什么,以及内存中如何排列这些字节**。对象的存储有两个通用的规则:

* 小端法(little endian),最低有效字节在最前面的方式。
* 大端法(big endian),最高有效字节在最前面的方式。
* **小端法**(little endian): 在内存中选择按照从变量最低有效字节(更小数值的那部分)到最高有效字节的顺序存储对象,即最低有效字节在最前面的方式。
* **大端法**(big endian): 在内存中选择按照从最高有效字节到最低有效字节的顺序存储对象,即最高有效字节在最前面的方式。

如下图所示,对于变量 $x$,假设其存储地址为 0x100,其十六进制值为 0x1234567,如果存储方式是小端法,那么内存中的存储顺序为 67、45、23、01(对应内存地址是0x100, 0x101, 0x102, 0x103),如果存储方式是大端法,那么内存中的存储顺序为 01、23、45、67。

![image](images/ymZPakWiwkFaKtCt9yb5GwYbw2cl2kt66aKr1pSVoQ8.png)

Expand Down

0 comments on commit 5a75a95

Please sign in to comment.