Welcome to MSDN Blogs Sign in | Join | Help

Which end of the egg do you crack. Putting it differently, what is your Endianess

Mr.Egg

Few people seem to know that the word Endianess comes from Gullivers travels. In Gulliver's travel where there were two types of people, the Lilliputs who cracked the small side of their soft boiled eggs and the Blefuscu who used the big side (Big-Endian). Since I'm well networked these days (over Orkut/Facebook/LinkedIn) I make a conscious decision to be Big-Endian while cracking an egg as its the preferred network endianess.

I do not want to delve into the holy endianess war especially because most modern processors allow hardware/software methods to switch it (reminds me of some politicians though :))

However, I do use bit/byte questions as the acid test for fly/no-fly interviews as suggested by this guy. One of them involves asking about the whole endianess business and a code snippet to find out the endianess of the current system. I'm usually looking for something as below

short a = 1;
    if (*((char *)&a) == 1)
        printf("Little Endian\n");
    else
        printf("Big Endian\n");
The idea is not to look for an exact code but to ensure that there's no complete ignorance of this area...
Published Thursday, April 17, 2008 10:42 AM by abhinaba
Filed under: , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Microsoft news and tips » Which end of the egg do you crack. Putting it differently, what is your Endianess

# re: Which end of the egg do you crack. Putting it differently, what is your Endianess

Thursday, April 17, 2008 4:54 AM by Ahmad

Enjoy this beautiful code.

#include <stdio.h>

void main()

{

int amazing[] ={544024393,1634560065,1495280740,1679848815,

   1948741231,1851881248,1830838638,544437097,

   1769105768,1830840174,539042149,1767992645,

   1701650540,2003791392,1835557152,1718183009,

   1835483256,778856801,560820067,555819297,1867259977,

   1293968758,1869767529,1952870259,555819264};

printf("%s",(char*)amazing);

getchar();

}

# re: Which end of the egg do you crack. Putting it differently, what is your Endianess

Thursday, April 17, 2008 4:56 AM by Ahmad

By the way. the code works on 32 BIT x86 Only :-)

# re: Which end of the egg do you crack. Putting it differently, what is your Endianess

Thursday, April 17, 2008 5:01 AM by Ahmad

I love this!!!

struct A

{

int a;

char b;

char i;

};

int num = ((int)&((A*)1)->i);

-------------------------------

int const mask = v >> sizeof(int) * 8 - 1;

r = (v + mask) ^ mask;

r = (v ^ mask) - mask; // Use this if you love getting your company sued LOL. Its patented!!

-------------------------------

int x,y,r;

x = -20;

y= -10;

r = y +((x-y)&-(x<y));

----------------------------------

How on earth do I get into Microsoft LOL!!!

# re: Which end of the egg do you crack. Putting it differently, what is your Endianess

Thursday, April 17, 2008 5:54 AM by abhinaba

Nah, not yet. As I told you this and a bunch of other such questions gives you the opportunity to fly for an interview :)

Then there's the other 4-5 rounds of real interview :)

# re: Which end of the egg do you crack. Putting it differently, what is your Endianess

Thursday, April 17, 2008 6:21 AM by Ahmad

Well ya but u know. Beyond a point Fortune and time matters :-).

I had an interview with you guys. I just couldnt perform GOD knows why :-) even though the questions were so lame I could not convey accross the table .

FATE!!!

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker