tags:

views:

93

answers:

3

After reading a series of man pages and searching through google, I decided to post this question to the bright folks of stack overflow.

I'm working on a basic Unix Shell and one of the requirements is that I have to implement a command to echo out the shell's pid in base 10 ASCII... Before I read this requirement, I had assumed that process id's were already base 10 numbers. Does anyone know if this is true?

+3  A: 

Technically speaking, the numbers that are returned by getpid() are in base two. :-)

Seriously speaking, the requirement probably just means that the number should be displayed as a decimal number as opposed to, for example, a hexadecimal number. I would ask for clarification of that requirement though, since you had to ask.

In silico
I thought as much, thanks for the quick response.
Jeff
+1 for the "technically speaking" :-)
R..
A: 

Of course, they are [printed in base 10 by system utilities].

tvanfosson
+3  A: 

Numbers themselves don't have a base. They just represent a value. If you have seventeen goats unicorns, then you still have the same number of unicorns no matter what base you choose to write that down in.

Once you decide to print a value using a human readable representation, then you have to choose a base. Your requirement is that the user expects to see the PID in a base 10 representation.

Greg Hewgill