記憶體 little endian big endian
0x00 0x44 0x11
0x01 0x33 0x22
0x02 0x22 0x33
0x03 0x11 0x44
所以換個方式想
ex:0x1
記憶體 little endian big endian
0x00 0x1 0x0
0x01 0x0 0x0
0x02 0x0 0x0
0x03 0x0 0x0
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
unsigned int value = 0x1;
char *BytePtr = (char*)&value;
if(*BytePtr)
printf("little endian\n");
else
printf("big endian");
return 0;
}
而通常會用在embedded system , 雖然大多數都是little endian
沒有留言:
張貼留言