Wednesday, November 21, 2007

Finding the limits on Mac OS X PPC Architecture

The first exercise in Kernighan and Ritchie asks that we find out the ranges of char, short, int and long variables by writing a program. It also gives a hint just above this question by telling us that the symbolic constants are in the standard header files such as . Now all we have to do is to include this file in our program and access the variables.

So if we begin with the end in mind, here is our path
1. Print the ranges of variable class e.g. short, int
2. These values can be found in the header files such as
3. Find the header file
4. Get the ranges
5. Include the header file in your program
6. Access the variable values as symbolic constant

The tricky part is step 3 i.e. to find where the header file is located especially on my Mac. Here is how I found the file
1. I need to use command line and go to the root.
2. cd /
3. This file will most likely be in usr
4. cd /usr
5. There is an include directory. Our file will most likely be here.
6. cd include
7. OK. Doing ls in the include directory gave me a long list of files
8. Now I know that my Mac has powerpc architecture. So I went in the directory ppc
9. cd ppc
10. Found the file.

Now, of course, this is not as intuitive as above and there were some trial and error involved. But I will spare the details and just give the clean solution.

So the final location of the limits.h file is
/usr/include/ppc

And the ranges of the variables on my computer are
Size of Char 8
Size of Char Max 127
Size of Char Min -128
Size of int min -2147483648
Size of int max 2147483647
Size of long min -2147483648
Size of long max 2147483647
Size of short min -32768
Size of short max 32767
Size of unsigned char 255
Size of unsigned long 4294967295
Size of unsigned int 4294967295
Size of unsigned short 65535

Thursday, November 15, 2007

Is it just me .... or did it say Chicago?

I watch Frasier everyday. It is my most favourite show. Nowadays it is all re-runs. But it is still a delight to watch this elegant and eccentric, well mannered and maverick, funny and a little naive radio-host cum shrink.

So in today's episode, Frasier is supposed to move to San Francisco for his new job on TV and he tells everyone about it and boards the flight. On the flight he meets a lovely lady and tells her his story. Interestingly, when the flight is landing, the PA says "Welcome to Chicago".

Hmmm..... did I miss something?

Tuesday, November 13, 2007

Turning 28... with the buzz of the pager

So I turned 28 today. Yesterday and until I went to bed, I had made so many plans regarding how I will start my birthday, make new resolutions, plan for the year ahead etc. etc.

So thinking of that I went to sleep and all of a sudden....
BeepBeep.... BeepBeepBeep.... BeepBeepBeepBeep...... . Man! That's my pager. Is it? Am I sure someone has not sent me SMS to wish my happy birthday. No way! I can distinguish my pager's sound from a mile! Yes, it was my pager telling me that I needed to log on immediately and respond to some potential problem, of course.

Well, so I logged in, checked message, responded to the situation and now I will be going back to sleep again.