## 3. Integer

The integer data type is used to store whole numbers - i.e. those without a decimal point.

For example

1234 is an integer

1234.0 is **not** an integer

An integer can deal with both positive and negative whole numbers.

If you try and store a decimal number in an integer data type, it will cut off everything after the decimal point, which is likely to cause a problem with the program later down the line. This 'type error' can be quite difficult to spot.

```
int MyInteger
MyInteger = 1.234
```

The number in MyInteger will actally be 1, with the decimal part discarded.

#### Number size matters

Many computer languages (such as 'C') break down integer into different types depending on the kind of numbers you wish to store in it - its size and sign matter a great deal.

**unsigned int** - can only store positive numbers up to 64,000. It cannot store negative whole numbers.

**signed int** - stores both positive and negative numbers but with only half the range of an unsigned int as one half of the range is dedicated to negative numbers. For example +/- 32000 rather than 0 to +64000

**short int **- it only uses a single word (16 bits) for storage so the number must not be larger than about 32,000, or +/-16,000 if it's signed.

**long int** - it uses two words (32 bits) for storage and can handle huge numbers, but it is wasteful of memory for small numbers.

**Challenge** see if you can find out one extra fact on this topic that we haven't
already told you

Click on this link: integer data type