(See Eric’s answer for more detailed explanation)
Notes:
- Generally,
intis set to the ‘natural size’ – the integer form that the hardware handles most efficiently - When using
shortin an array or in arithmetic operations, theshortinteger is converted intoint, and so this can introduce a hit on the speed in processingshortintegers - Using
shortcan conserve memory if it is narrower thanint, which can be important when using a large array - Your program will use more memory in a 32-bit
intsystem compared to a 16-bitintsystem
Conclusion:
- Use
intunless you conserving memory is critical, or your program uses a lot of memory (e.g. many arrays). In that case, useshort.