Dolby Interview Question

Write a program to test endianess of storage.

Interview Answers

Anonymous

Dec 4, 2012

#define LITTLE_ENDIAN 0 #define BIG_ENDIAN 1 int EndiannessTest() { int i = 1; char *p = (char *) &i; if (p[0] == 1) // Lowest address contains the least significant byte return LITTLE_ENDIAN; else return BIG_ENDIAN; }

10

Anonymous

Apr 17, 2011

I described a method that placed a 1 byte word into a 2 byte address. If the word was matched in the upper MSB, it was Big endian, otherwise small endian.

1

Anonymous

Jul 16, 2011

use union property to judge if it is big endian or little endian.

3