Big endian and Little endian computers
来源:百度文库 编辑:神马文学网 时间:2024/05/15 22:54:11
Virtually all computer architectures are byte addressable. Ifan int is four bytes, there are two different ways to store this.Suppose the address of the int is A. In a so-called big endiancomputer, the highest order byte is stored at A, and the lowestorder byte is stored at address A+3. In a so-called littleendian computer, address A stores the least significant byteand the most significant byte is at address A+3.
Big endian computer architectures include the IBM 370,the Motorola 68000 and Sun Sparc. Little endian computersinclude the intel series (80486, pentium etc) and VAX.
Consider the decimal integer 91,329. This is 00 01 64 C1in hexidecimal. If this were to be stored at address Ain a big endian computer, 00 would be at address A,01 at address A+1 64 at address A+2, and C1 at addressA+3. On a little endian computer, C1 would be the valueat address A, 64 at address A+1, 01 at address A+2,and 00 at address A+3.
Computer networks are big endian. This means that whenlittle endian computers are going to pass integersover the network (IP addresses for example), they needto convert them to network byte order. Likewise, when thereceive integer values over the network, they need toconvert them back to their own native representation.
There are four functions that do this.
unsigned long htonl(unsigned long)host to network conversion for long ints (4 bytes)unsigned short htons(unsigned short)host to network conversion for short ints (2 bytes)unsigned long ntohl(unsigned long)network to host conversion for long intsunsigned short ntohs(short)network to host conversion for short intsOn big endian computers these functions simply return theirarguments.
The terms big endian and little endian are borrowed fromGulliver‘s Travels.
Big endian computer architectures include the IBM 370,the Motorola 68000 and Sun Sparc. Little endian computersinclude the intel series (80486, pentium etc) and VAX.
Consider the decimal integer 91,329. This is 00 01 64 C1in hexidecimal. If this were to be stored at address Ain a big endian computer, 00 would be at address A,01 at address A+1 64 at address A+2, and C1 at addressA+3. On a little endian computer, C1 would be the valueat address A, 64 at address A+1, 01 at address A+2,and 00 at address A+3.
Computer networks are big endian. This means that whenlittle endian computers are going to pass integersover the network (IP addresses for example), they needto convert them to network byte order. Likewise, when thereceive integer values over the network, they need toconvert them back to their own native representation.
There are four functions that do this.
unsigned long htonl(unsigned long)host to network conversion for long ints (4 bytes)unsigned short htons(unsigned short)host to network conversion for short ints (2 bytes)unsigned long ntohl(unsigned long)network to host conversion for long intsunsigned short ntohs(short)network to host conversion for short intsOn big endian computers these functions simply return theirarguments.
The terms big endian and little endian are borrowed fromGulliver‘s Travels.
Big endian and Little endian computers
Big-endian和little-endian
Big Endian 和 Little Endian
Big Endian 和 Little Endian
Big Endian and Little Endian(字节序)
big-endian and little-endian - C语言技巧讨论 - jiuz...
little/big endian
Big Endian和Little Endian的区别
Big Endian 和 Little Endian [转]--Verilog Bird
博客园 - 航行日记 - BIG Endian 和 Small Endian模式的区别(摘自其他网站)
unicode,ansi,utf-8,unicode big endian这些编码有什么区别
大小端 地址空间 alignment,endian
Endian的由来 【转】_急速星雨
Iniesta, little man for the big occasion
Deadly tick bite: Little bug, big problem
‘Volunteer spirit‘ and a big helping of greens
The Big China and Taiwan Tussle: Dollar Diplo...
TIGERS, LIONS AND BIG CATS IN ACTION Photo Ga...
‘Volunteer spirit‘ and a big helping of greens
ScienceDirect - Computers & Education : Engaging college science students and changing academic achievement with technology: A quasi-experimental preliminary investigation
BIG BIG GIRL
Little Britain
little girl
Big Catch