Monday, June 20, 2011

Big Endian and Little Endian

  • What is the difference between big endian and little endin machines

The data ordering at the memory is different for them, in little endian higher address have the most significant byte and lower have the least signifincant byte. and otherway round in case of big endian machines.

  • How do u determine a processor to be little endian or big endian, write a small program for it.

int a = 1;
if( *((char *)&a) == 1) 
    printf("Little endian");
    printf("Big Endian");

This can also be done using an eum as shown below

  int a;
  char c[4];

a = 1;
if(char[1] == 1) 
    printf("Little Endian");
    printf("Big Endian");

No comments:

Post a Comment