A sample illustrate the differences between Big-endian and Little-endian:
A simple program for endianess detecting:
Consider the number 1025 (2 to the tenth power plus one) stored in a 4-byte integer:
00000000 00000000 00000100 00000001
Address Big-Endian representation of 1025 Little-Endian representation of 1025 00
01
02
0300000000
00000000
00000100
0000000100000001
00000100
00000000
A simple program for endianess detecting:
#include <stdio.h>
int main()
{
int x=1;
if (*((char *)&x)==1)
printf("Little endian.\n");
else
printf("Big endian.\n");
return 0;
}
More about endianess, referer to wikipedia/Endianness

没有评论:
发表评论