1. ## signed or unsigned?

If I wanted a number that went from 0 to 10,000, which would be the better option (for speed, effeciency, etc.) and why?

signed short SSExample = 0;
unsigned short USExample = 0;
signed int SIExample = 0;
unsigned int UIExample = 0;

I'm just curious. In order of best to worst, which goes where?

2. Well it fits in a short, so save 2 bytes... I'd use an signed short int in this case, for example if I wanted to flag an error I could set SSExample to -1. But if you don't plan on using it for that, use an unsigned short int

3. Considering the target is most likely a PC, I might go with the following for speed:
Code:
```short SSExample = 0; /*4 */
unsigned short USExample = 0; /* 3 */
int SIExample = 0; /* 2 */
unsigned int UIExample = 0; /* 1 */```
And for size:
Code:
```short SSExample = 0; /*2 */
unsigned short USExample = 0; /* 1 */
int SIExample = 0; /* 4 */
unsigned int UIExample = 0; /* 3 */```
When signedness doesn't matter, always prefer unsigned (just because*). When size matters, choose the appropriate size. When speed matters, favor the compiler's favorite choice. When other platforms matter, make a different choice. Avoid short types, default promotions are not an enjoyable consideration.

*Or perhaps because the math is generally more well-defined.

4. Originally Posted by zacs7
Well it fits in a short, so save 2 bytes... I'd use an signed short int in this case, for example if I wanted to flag an error I could set SSExample to -1. But if you don't plan on using it for that, use an unsigned short int
If SSExample is an unsigned short, you can use (unsigned short)(-1) (== 65535 for a 16-bit unsigned short) as the flag.

5. Originally Posted by robatino
If SSExample is an unsigned short, you can use (unsigned short)(-1) (== 65535 for a 16-bit unsigned short) as the flag.
I'd rather not do that, since it avoids confusion this way... Most if not all of the standard C funcs are set out in this manner.

6. So, basically, unsigned is better and faster for speed?

7. Originally Posted by ulillillia
So, basically, unsigned is better and faster for speed?
I'll take the 5th, or rather, claim that is at least as well-defined; I'll leave the rest to the implementors for the moment.

Or make assumptions and go with "yes".

8. Just use "int". It's not the shortest to type just by accident.
It is made to be the shortest to type because it is most often the best choice in terms of performance etc, regardless of the register size of the machine.