Jeff
Jeff

Reputation: 633

Are unix process ID's base 10?

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?

Upvotes: 1

Views: 307

Answers (3)

In silico
In silico

Reputation: 52149

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.

Upvotes: 3

Greg Hewgill
Greg Hewgill

Reputation: 993015

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.

Upvotes: 3

tvanfosson
tvanfosson

Reputation: 532435

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

Upvotes: 0

Related Questions