Which end of the egg do you crack. Putting it differently, what is your Endianess
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...
Comments
Anonymous
April 16, 2008
PingBack from http://microsoftnews.askpcdoc.com/?p=2980Anonymous
April 16, 2008
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(); }Anonymous
April 16, 2008
By the way. the code works on 32 BIT x86 Only :-)Anonymous
April 16, 2008
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!!!
Anonymous
April 16, 2008
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 :)Anonymous
April 16, 2008
The comment has been removed