大小端模式、网络字节序

1.内存简介

地址线根数	        对应范围				空间大小		       计算过程
8			00~FF				256B			2^8 = 256B
16			0000~FFFF			62K			2^16 = 2^6K = 64K
20			00000~FFFFF			1M			2^20 = 2^10K = 1M
24			000000~FFFFFF		        16M			2^24 = 2^4*M = 16M
28			0000000~FFFFFFF		        256M		        2^28 = 2^8 M = 256M
32			00000000~FFFFFFFF		4G			2^32 = 2^2*G = 4G	

 下面以unsigned int value = 0x12345678为例,分别看看在两种字节序下其存储情况 :

 
1.大端模式(Big-endian

   高尾端:数据的高字节保存在内存的低地址中。 

  Big-Endian: 低地址存放高位,如下:
 
  高地址   
  ---------------   
  buf[3] (0x78) -- 低位   
  buf[2] (0x56)   
  buf[1] (0x34)   
  buf[0] (0x12) -- 高字节  
  ---------------   
  低地址

 

2.小端模式(Little-Endian

  低尾端:数据的低字节保存在内存的低地址中。

 
 Little-Endian: 低地址存放低位,如下:
 高地址   
 ---------------   
 buf[3] (0x12) -- 高位   
 buf[2] (0x34)   
 buf[1] (0x56)   
 buf[0] (0x78) -- 低字节   
 --------------
 低地址
 
内存地址 小端模式存放内容 大端模式存放内容
0x4000 0x78 0x12
0x4001 0x56 0x34
0x4002 0x34 0x56
0x4003 0x12 0x78

3.微软 采用:   小端模式

4.网络字节序:大端模式

 

posted @ 2018-04-30 19:05  <--青青子衿-->  阅读(251)  评论(0编辑  收藏  举报
// /**/ // 在页脚Html代码 引入 // function btn_donateClick() { var DivPopup = document.getElementById('Div_popup'); var DivMasklayer = document.getElementById('div_masklayer'); DivMasklayer.style.display = 'block'; DivPopup.style.display = 'block'; var h = Div_popup.clientHeight; with (Div_popup.style) { marginTop = -h / 2 + 'px'; } } function MasklayerClick() { var masklayer = document.getElementById('div_masklayer'); var divImg = document.getElementById("Div_popup"); masklayer.style.display = "none"; divImg.style.display = "none"; } setTimeout( function () { document.getElementById('div_masklayer').onclick = MasklayerClick; document.getElementById('btn_donate').onclick = btn_donateClick; var a_gzw = document.getElementById("guanzhuwo"); a_gzw.href = "javascript:void(0);"; $("#guanzhuwo").attr("onclick","follow('33513f9f-ba13-e011-ac81-842b2b196315');"); }, 900);