The naming and usage of integers in Diku derivatives has always been sporadic and strange, though some of that may be because some of the software is very old.
In general, Zeno is correct. If you plan on a number going over ~32k you will want to use int, otherwise sh_int should be fine.
In a professional environment you would see more discretion (well, I would hope you see more, but I'm an embedded systems programmer so it actually matters to me) as to which you use. Each integer also has an unsigned variant that will remove signage from your number, giving you a larger range starting from 0. Below is a brief description in case you don't want to wade through the link Zeno posted.
Typically the layout is thus:
char = 1-byte, values -127 to 128, 0-255 unsigned
short = 2-bytes, values -32,768 to 32,767, 0-65,535 unsigned
int = 4-bytes, values -2,147,483,648 to 2,147,483,647, unsigned 0-4,294,967,295
Most people writing serious code will have a types file that accounts for system variations (such as what long's stand for :) and generalize them to:
sint8 / uint8
sint16 / uint16
sint32 / uint32
sint being signed int, uint being unsigned int.
This takes some of the guesswork out. More or less you should always pick the smallest possible choice for your problem, which helps you be efficient with your memory and track down errors.
As you will see, though, now that RAM is huge, people are very careless and just throw int's at everything. For hobbyist projects like MUDs that may be fine (and you'll see it everywhere in your code base), but if you want to become a decent programmer try to keep these rules in mind.
I would say you should error on the side of unsigned integers (as most systems do), but that would probably cause a lot of type issues in many of the more common MUD code bases these days.
|