Integer Types

Integers comprise several sizes, all determined by how many bytes of storage they require and whether they can hold signed numbers (i.e. negative numbers) or unsigned. There are four sizes of integers: one, two, four and eight bytes, each with signed and unsigned versions. These are usually described by how many bits they occupy. The four sizes are 1, 2, 4 and 8 bytes.

The four signed types
8 bits1sbyte-128 to +127
16 bits2short-32768 to +32767
32 bits4int-2,147,483,648 to +2,147,483,647
64 bits8long-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
The four unsigned types
8 bits1byte0 to 255
16 bits2ushort0 to 65535
32 bits4uint0 to 4,294,967,295
64 bits8ulong0 to 18,446,744,073,709,551,615

As a general rule of thumb, you'll find that int, the signed 32 bit type, will be all you need for probably 90% of applications that you write, especially if you are working on a 32 bit CPU or Operating System. Using a smaller size int than the machine size may not be faster. In fact, it may be slower as a 32 bit CPU retrieves data in 32 bit size chunks.

Integers, no matter what size, are probably the most commonly used type as they are required for looping, indexing and counting.