Data goes through the central processing unit which utilises main and cache memory to improve system performance. Peripherals use interfaces to communicate between the system and a connected device.

Binary is used to represent whole numbers so that they can be understood by the processor.

An **integer**:

- is a whole number
- can be a positive number or a negative number

The number 173 is an integer. It can be represented in binary as:

**10101101**

Binary works using a number system that is based on powers of 2. To understand why 10101101 is the same as 173 look at the following table:

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

(2^{7}) | (2^{6}) | (2^{5}) | (2^{4}) | (2^{3}) | (2^{2}) | (2^{1}) | (2^{0}) |

1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |

ON | OFF | ON | OFF | ON | ON | OFF | ON |

When adding up all of the values that are on, the following sum is created:

**128 + 32 + 8 + 4 + 1 = 173**

In this example we are using 8 bits to represent a number. If we use 8 bits we can represent any number between 0 and 255.

If all of the values are off, the number is 0:

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

(2^{7}) | (2^{6}) | (2^{5}) | (2^{4}) | (2^{3}) | (2^{2}) | (2^{1}) | (2^{0}) |

0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |

OFF | OFF | OFF | OFF | OFF | OFF | OFF | OFF |

If all of the values are on, the number is 255:

128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

(2^{7}) | (2^{6}) | (2^{5}) | (2^{4}) | (2^{3}) | (2^{2}) | (2^{1}) | (2^{0}) |

1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |

ON | ON | ON | ON | ON | ON | ON | ON |

**128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255**

To figure out the range of numbers that can be stored with a set number of bits, use the following formula:

**2 ^{n} - 1**

The reason for taking one away is because the integer 0 needs to be stored.

**2 ^{8} = 256**

**2 ^{8} - 1 = 255**

This means that the range of integers that can be represented using 8 bits is 0 – 255. Typically we categorise binary in groups of 8 bits (or 1 byte).

Number of bits | Formula | Range |
---|---|---|

8 | 2^{8} - 1 | 0 - 255 |

16 | 2^{16} - 1 | 0 - 65,535 |

24 | 2^{24} - 1 | 0 - 16,777,215 |

32 | 2^{32} - 1 | 0 - 4, 294,967,295 |